Google API quickstart.py 错误 KeyError: '_module' [英] Google API quickstart.py error KeyError: '_module'
问题描述
使用 Gmail API.我的客户端机密文件已下载并适用于 Ruby.当我尝试 quickstart.py (python) 版本时,我收到此错误
Using Gmail API. My client secret file is downloaded and working for Ruby. When I try the quickstart.py (python) version I get this error
File "quickstart.py", line 70, in <module>
main()
File "quickstart.py", line 55, in main
credentials = get_credentials()
File "quickstart.py", line 38, in get_credentials
credentials = store.get()
File "/Library/Python/2.7/site-packages/oauth2client/client.py", line 374, in get
return self.locked_get()
File "/Library/Python/2.7/site-packages/oauth2client/file.py", line 79, in locked_get
credentials = Credentials.new_from_json(content)
File "/Library/Python/2.7/site-packages/oauth2client/client.py", line 281, in new_from_json
module = data['_module']
KeyError: '_module'
我根本没有更改文件,只是将 client_secret.json 添加到该工作目录并安装了 google-api-python-client.我的 python 代码来自这里:https://developers.google.com/gmail/api/快速入门/python
I have not changed the file at all, just added the client_secret.json to that working directory and also install the google-api-python-client. My python code came from here: https://developers.google.com/gmail/api/quickstart/python
推荐答案
尝试将 creds = store.get()
暂时替换为 creds = None
.如果可行,您可以重构代码以始终从基于流的凭据实例化开始.这对我有用.Google 样本似乎与其 oauth2client 不同步.
Try replacing creds = store.get()
with creds = None
temporarily. If this works, you can refactor your code to always start with flow-based credentials instantiation. This worked for me. It seems Google samples are out of sync with their oauth2client.
这篇关于Google API quickstart.py 错误 KeyError: '_module'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!