【发布时间】:2014-05-20 04:47:58
【问题描述】:
我使用this code 从我的 GAE 应用程序访问 Google API:
scope = "https://www.googleapis.com/auth/urlshortener"
authorization_token, _ = app_identity.get_access_token(scope)
它适用于生产环境,但不适用于开发环境:
Using token InvalidToken:https://www.googleapis.com/auth/urlshortener:77.5780799389 to represent identity test@localhost
('Call failed. Status code %s. Body %s', 401L, '{\n "error": {\n "errors": [\n {\n "domain": "global",\n "reason": "authError",\n "message": "Invalid Credentials",\n "locationType": "header",\n "location": "Authorization"\n }\n ],\n "code": 401,\n "message": "Invalid Credentials"\n }\n}\n')
我可以应用任何解决方法(但不能从头开始实施 OAuth)吗?
更新。从开发环境访问 Google API 的另一种方法也不起作用:
credentials = AppAssertionCredentials(scope='https://www.googleapis.com/auth/analytics.readonly')
http = credentials.authorize(httplib2.Http(memcache))
service = build('analytics', 'v3', http=http)
response = service.management().accounts().list().execute()
logging.info(response)
【问题讨论】:
标签: google-app-engine google-api google-oauth