Gdata python谷歌应用程序身份验证

kar*_*hik 6 python gdata oauth-2.0

我已经能够使用client.programmaticlogingdata下载包中的示例/电子表格,使用gdata python 函数登录Google电子表格.

现在我无法登录我的企业gapps'me@mycompany.com'我是否必须通过任何其他武器?我试过帐户类型托管没有工作.

我尝试oath2从gui 创建密钥,我生成了客户端ID和电子邮件ID.在gdata中运行oauth示例会询问consumerkey和secret密钥.有人可以就此提出建议吗?

kar*_*hik 7

好吧,我用下面的解决方案解决了

import gdata.gauth

Client_id='xxx';
Client_secret='yyy'
Scope='https://spreadsheets.google.com/feeds/'
User_agent='myself'

token = gdata.gauth.OAuth2Token(client_id=Client_id,client_secret=Client_secret,scope=Scope,user_agent=User_agent)
print token.generate_authorize_url(redirect_uri='urn:ietf:wg:oauth:2.0:oob')
code = raw_input('What is the verification code? ').strip()
token.get_access_token(code)
print "Refresh token\n"
print token.refresh_token
print "Access Token\n"
print token.access_token
Run Code Online (Sandbox Code Playgroud)