【发布时间】:2014-12-22 23:54:32
【问题描述】:
我正在使用 OAuth2WebServerFlow 来获取用户的表格凭据以与 gdata/spreadsheets API 一起使用。我很难诊断这个问题,因为当我在本地运行应用程序时它可以完美运行。
这是我用来获取授权 URL 的 sn-p:
CLIENT_ID = 'my-id'
CLIENT_SECRET = 'my-secret'
SCOPE = 'https://spreadsheets.google.com/feeds'
flow_object = OAuth2WebServerFlow(CLIENT_ID, CLIENT_SECRET, SCOPE, redirect_uri=self.REDIRECT_URL, access_type='online')
authorize_url = flow_object.step1_get_authorize_url()
本地(使用REDIRECT_URL = 'http://localhost:8080/this-path/')
这会产生:
https://accounts.google.com/o/oauth2/auth?redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fthis-path%2F&scope=https%3A%2F%2Fspreadsheets.google.com%2Ffeeds&client_id=my-id&response_type=code&access_type=online
在实时 App Engine 应用程序上(使用 REDIRECT_URL = 'http://my-app.appspot.com/this-path/')
这会产生:
https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fspreadsheets.google.com%2Ffeeds&redirect_uri=http%3A%2F%2Fmy-app.appspot.com%2Fthis-path%2F&response_type=code&client_id=my-id&access_type=online
应用程序配置如下:
CLIENT ID: my-id
EMAIL ADDRESS: my-id@developer.gserviceaccount.com
CLIENT SECRET: my-secret
REDIRECT URIS:
http://localhost:8080/
http://my-app.appspot.com
https://my-app.appspot.com
http://my-app.appspot.com/this-path
https://my-app.appspot.com/this-path
http://my-app.appspot.com/this-path/
https://my-app.appspot.com/this-path/
JAVASCRIPT ORIGINS
http://localhost:8080
http://my-app.appspot.com
转到本地生成的url版本我可以成功授予应用程序权限。但是在我的实时应用程序生成的 url 上,我得到一个 401,上面写着“错误:disabled_client OAuth 客户端被禁用”。
我觉得它可能只是一个配置错误。也许它在本地工作的事实只是一个红鲱鱼?也许我总是能够授予 localhost 这些权限?我真的对此一无所知,我们将不胜感激。
【问题讨论】:
标签: google-app-engine oauth oauth-2.0 google-oauth gdata