linux - 谷歌 API OAuth2.0 quickstart.py

标签 linux python-2.7 ubuntu google-api google-api-python-client

当我使用 Google API 中提供的 Quickstart.py 代码示例时,出现此错误。关于为什么会产生此错误的任何想法? 链接:https://developers.google.com/google-apps/calendar/quickstart/python (我已经更新了 oauth2cilent 模块)

/home/akhil/anaconda2/lib/python2.7/site-
packages/oauth2client/_helpers.py:255: UserWarning: Cannot access 
storage.json: No such file or directory
warnings.warn(_MISSING_FILE_MESSAGE.format(filename))
Traceback (most recent call last):
File "/home/akhil/Desktop/TIME_SCHEDULE_UPDATER/quickstart.py", line 
16, in <module>
flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
File "/home/akhil/anaconda2/lib/python2.7/site-
packages/oauth2client/_helpers.py", line 133, in positional_wrapper
return wrapped(*args, **kwargs)
File "/home/akhil/anaconda2/lib/python2.7/site-
packages/oauth2client/client.py", line 2134, in 
flow_from_clientsecrets
cache=cache)
File "/home/akhil/anaconda2/lib/python2.7/site-
packages/oauth2client/clientsecrets.py", line 165, in loadfile
return _loadfile(filename)
File "/home/akhil/anaconda2/lib/python2.7/site-
packages/oauth2client/clientsecrets.py", line 126, in _loadfile
return _validate_clientsecrets(obj)
File "/home/akhil/anaconda2/lib/python2.7/site-
packages/oauth2client/clientsecrets.py", line 101, in 
_validate_clientsecrets
prop_name, client_type))
oauth2client.clientsecrets.InvalidClientSecretsError: Missing property 
"redirect_uris" in a client type of "web".

最佳答案

在您的 client_secret.json 文件中,在末尾添加 redirect_uris block 。 你的文件应该是这样的: {"web":{"client_id":"foo","project_id":"bar","auth_uri":"foo","token_uri":"bar","auth_provider_x509_cert_url":"foo","client_secret": "bar", "redirect_uris":"http://domain_name _where_you_want_to_redirect/"}}

关于linux - 谷歌 API OAuth2.0 quickstart.py,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44312994/

相关文章:

sockets - 将 bytearray 与 socket.recv_into 一起使用

c++ - 无法创建超过 5 个 Mqueue

linux - Jenkins 上带有单声道的 MSBUILD

python-2.7 - 在 Ubuntu AWS 上使用 Python GUI 编辑器

c++ - 代码在 Linux 上运行良好,但在 Windows 操作系统上提供不同的输出

python - 使用 beautifulsoup 从多个 url 中抓取

python - 无损 PDF 旋转

mysql - Ubuntu连接拒绝数据库连接

c++ - Linux 上的 x86 C++ 开发存在哪些(有效的)备用工具链?

c - Pthread 程序在 Codeblocks 和 Linux Kernel 上打印不同的值