【发布时间】:2022-10-06 03:23:38
【问题描述】:
我通过使用 OAuth 2.0 方法的 python 连接到 bigquery 来访问用户数据。但是每次我进行查询时,它都会反复要求浏览器确认。如何取消此验证?当我将 launch_browser 值设置为 False 时,它会请求终端确认。我可以使用其他方法吗?我正在使用文档https://cloud.google.com/bigquery/docs/authentication/end-user-installed 中的相同示例代码
from google_auth_oauthlib import flow
from google.cloud import bigquery
launch_browser = True
appflow = flow.InstalledAppFlow.from_client_secrets_file(
\"client_secrets.json\", scopes=[\"https://www.googleapis.com/auth/bigquery\"]
)
if launch_browser:
appflow.run_local_server()
else:
appflow.run_console()
credentials = appflow.credentials
project = \'user-project-id\'
client = bigquery.Client(project=project, credentials=credentials)
query_string = \"\"\"SELECT name, SUM(number) as total
FROM `bigquery-public-data.usa_names.usa_1910_current`
WHERE name = \'William\'
GROUP BY name;
\"\"\"
query_job = client.query(query_string)
for row in query_job.result():
print(\"{}: {}\".format(row[\"name\"], row[\"total\"]))
-
您能否提供您所指的
browser confirmation的屏幕截图?