如何自动化oauth流来检索凭据?

时间:2016-10-10 19:46:28

标签: python oauth google-analytics-api

我正在创建一个python脚本,该脚本调用google analytics api获取一些实时数据,然后将其存储在数据库中。但是在调用api之前我必须得到oauth令牌。

这是我到目前为止通过点击链接,获取验证码,然后将其粘贴到控制台中而需要一些手工劳动,如下所示:

flow = OAuth2WebServerFlow(o['installed']['client_id'], o['installed']['client_secret'], ga_real_scope, o['installed']['redirect_uris'][0])
authorize_url = flow.step1_get_authorize_url()
print ('Go to the following link in your browser: {0}'.format(authorize_url))
code = input('Enter verification code: ').strip()
credentials = flow.step2_exchange(code)

有没有办法在不使用像Selenium这样的东西的情况下实现自动化?

0 个答案:

没有答案