Python 打电话给谷歌+;带令牌的API
如何使用python中的访问令牌调用Google+API,目前我使用的是flow方法,它首先交换身份验证url,然后交换凭证 我的代码是:Python 打电话给谷歌+;带令牌的API,python,google-app-engine,google-api,google-plus,google-oauth,Python,Google App Engine,Google Api,Google Plus,Google Oauth,如何使用python中的访问令牌调用Google+API,目前我使用的是flow方法,它首先交换身份验证url,然后交换凭证 我的代码是: FLOW = OAuth2WebServerFlow( client_id=client id, client_secret=secret, scope=scope, user_agent=user_agent,redirect_uri=redirect_uri) auth_uri = FLO
FLOW = OAuth2WebServerFlow(
client_id=client id,
client_secret=secret,
scope=scope,
user_agent=user_agent,redirect_uri=redirect_uri)
auth_uri = FLOW.step1_get_authorize_url()
credentials=FLOW.step2_exchange(code)
people_service = apiclient.discovery.build('people', 'v1',credentials=credentials)
connections = people_service.people().connections().list(resourceName='people/me').execute()
您需要实际访问
auth_uri
网页,用户将登录并获取身份验证代码,它将重定向回您的应用程序。在非浏览器应用程序中,您可以使用带外(OOB)和
redirect\u uri='urn:ietf:wg:oauth:2.0:OOB'
执行此操作,您可以打印(auth\u uri)
,将其剪切并粘贴到浏览器地址栏中,并输入用户凭据
当您获得身份验证代码时,需要将其分配给上面脚本中的code
,例如(对于OOB):
那么剩下的代码就可以正常工作了
我会考虑查看<代码> OAuthCudio.Sturue模块来存储从
auth\u uri
网页,用户将登录并获取身份验证代码,然后它将重定向回您的应用程序。在非浏览器应用程序中,您可以使用带外(OOB)和
redirect\u uri='urn:ietf:wg:oauth:2.0:OOB'
执行此操作,您可以打印(auth\u uri)
,将其剪切并粘贴到浏览器地址栏中,并输入用户凭据
当您获得身份验证代码时,需要将其分配给上面脚本中的code
,例如(对于OOB):
那么剩下的代码就可以正常工作了
我会考虑查看<代码> OAuthCudio.Sturue模块来存储从
code = input("Code: ") # raw_input() in Py2