我正在使用OAuth2WebServerFlow獲取用戶的表格憑證以與gdata/spreadsheets API一起使用。我在診斷問題時非常困難,因爲當我在本地運行應用程序時它工作得非常完美。OAuth2WebServerFlow從本地主機運行,但不是來自真正的AppEngine實例
這是我使用獲取授權URL的片段:
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: [email protected]
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
要去網址我可以成功地授予應用程序權限的本地產生版本。但在我的實時應用程序生成的網址上,我得到一個401表示「錯誤:disabled_client OAuth客戶端被禁用」。
我覺得它可能只是一個配置錯誤。也許它在本地工作的事實只是一個紅鯡魚?也許我總是能夠授予localhost這些權限?我真的沒有這方面的想法,任何幫助將不勝感激。
所以我理解正確的,你說你認爲的路徑從字面上必須是 「oauth2callback」?我可以稍後再嘗試看看,但我很懷疑。特別是考慮到「oauth2callback」不在您用作參考的頁面上的任何地方。 – 2015-01-23 15:56:32