gpt4 book ai didi

oauth - 如何使用 Google Oauth 为 BigQuery 授权已安装的应用程序?

转载 作者:行者123 更新时间:2023-12-01 23:58:01 24 4
gpt4 key购买 nike

我已按照此处的所有说明进行操作:https://developers.google.com/bigquery/bigquery-api-quickstart

但无法使授权过程正常工作。即使我指定 urn: ietf:wg:oauth:2.0:oob 作为我的回调,生成的 URL 也会尝试 localhost。当我运行我的脚本时,我得到以下输出,网页打开但我从未被提示输入我的代码。我在这里做错了什么?我正在使用 API 快速入门页面底部的完整示例代码。

 % python bqexample.py
WARNING:root:This function, oauth2client.tools.run(), and the use of the gflags library are deprecated and will be removed in a future version of the library.
Your browser has been opened to visit:

https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fbigquery&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&response_type=code&client_id=(REMOVED).apps.googleusercontent.com&access_type=offline

If your browser is on a different machine then exit and re-run
this application with the command-line parameter

--noauth_local_webserver

最佳答案

看起来 oauth2client 更改为使用 argparse 而不是 gflags(即更改了注册标志的机制)。尝试更改当前显示的代码

credentials = run(flow, STORAGE)

import argparse
from oauth2client import tools
argparser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter,
parents=[tools.argparser])
flags = argparser.parse_args(sys.argv[1:])
credentials = tools.run_flow(flow, storage, flags)

那么,你应该可以跑

python bqexample.py --noauth_local_webserver

它会给你一个 URL 来剪切和粘贴,而不是试图启动一个网络服务器来自动化这个过程。

关于oauth - 如何使用 Google Oauth 为 BigQuery 授权已安装的应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22746733/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com