【发布时间】:2014-01-30 07:12:46
【问题描述】:
我是 Python 新手,也是使用 API 的新手,所以这可能是基本的……我可以提出我的初始请求,这会导致浏览器窗口打开。此时,用户必须在 Google 同意页面上进行选择。之后返回授权码......我明白了。我的问题是,如何暂停我的 python 代码运行,以便等待用户许可并存储下一步所需的代码?我只是使用他们的库在 Python 2.7 中对其进行测试,但我坚持这一点。我可以在箭头上放什么?感谢任何帮助。
from oauth2client.client import OAuth2WebServerFlow
import webbrowser
flow = OAuth2WebServerFlow(client_id=[id],
client_secret=[secret],
scope='https://www.google.com/m8/feeds',
redirect_uri='urn:ietf:wg:oauth:2.0:oob')
auth_uri = flow.step1_get_authorize_url()
webbrowser.open(auth_uri)
--->
code=''
credentials = flow.step2_exchange(code)
【问题讨论】:
标签: api python-2.7 google-oauth google-contacts-api