我试图在我的本地计算机上使用Oauth连接到google驱动器。我最初尝试遵循这里概述的快速入门步骤https://developers.google.com/drive/v3/web/quickstart/python,但它无法连接。我会在授权屏幕上得到提示,然后单击“允许”,但随后会重定向到本地主机:8080错误响应消息和日志显示:
Your browser has been opened to visit:
If your browser is on a different machine then exit and re-run this application with the command-line parameter
--noauth_local_webserver
我随后尝试简单地使用代码来一步一步地完成它,但是我一直遇到同样的问题:没有返回访问代码,我无法进行身份验证。在
from httplib2 import Http
from oauth2client import file, client, tools
from oauth2client.client import flow_from_clientsecrets
store = file.Storage('credentials.json')
flow = flow_from_clientsecrets('client_secret.json',
scope='https://www.googleapis.com/auth/drive.metadata.readonly',
redirect_uri='http://example.com/auth_return')
print flow
creds = tools.run_flow(flow, store)
print 'access_token: {}'.format(creds.access_token)
service = build('drive', 'v3', http=creds.authorize(Http()))
有什么想法吗?在
为了认证到谷歌,你需要首先登录到你的谷歌帐户,然后批准授权。在
脚本告诉您导航到该页面并批准授权。在
如果它还没有为你打开,就在浏览器上打开它。在
您可以考虑遵循python quickstart
相关问题 更多 >
编程相关推荐