突然,在我的應用程序被授予用戶訪問權限並且授權代碼傳遞到我的重定向url後,Oauth進程中出現錯誤。我已經使用相同的代碼幾個星期了,它一直工作正常。我很確定我沒有做任何改變。交換Oauth代碼時出錯
今天Google Drive API有問題嗎?
這裏發生在Python代碼這裏的誤差:
credentials = flow.step2_exchange(authorization_code)
錯誤消息:
FlowExchangeError: Invalid response 400.
來自谷歌例如複製的整個EXCHANGE_CODE方法:
def exchange_code(authorization_code):
"""Exchange an authorization code for OAuth 2.0 credentials.
Args:
authorization_code: Authorization code to exchange for OAuth 2.0
credentials.
Returns:
oauth2client.client.OAuth2Credentials instance.
Raises:
CodeExchangeException: an error occurred.
"""
logging.debug(authorization_code);
flow = flow_from_clientsecrets(CLIENTSECRETS_LOCATION, ' '.join(SCOPES))
flow.redirect_uri = REDIRECT_URI
try:
credentials = flow.step2_exchange(authorization_code)
return credentials
except FlowExchangeError, error:
logging.error('An error occurred: %s', error)
raise CodeExchangeException(None)
使用OAuth遊樂場,我收到以下錯誤響應:
HTTP/1.1 400 Ok
Status: 400
Content-length: 37
X-xss-protection: 1; mode=block
X-content-type-options: nosniff
X-google-cache-control: remote-fetch
-content-encoding: gzip
Server: GSE
Via: HTTP/1.1 GWA
Pragma: no-cache
Cache-control: no-cache, no-store, max-age=0, must-revalidate
Date: Fri, 10 Aug 2012 03:23:54 GMT
X-frame-options: SAMEORIGIN
Content-type: application/json
Expires: Fri, 01 Jan 1990 00:00:00 GMT
{
"error" : "unauthorized_client"
}
任何想法,爲什麼這將開始發生時,代碼工作幾周,因爲它是現在?
謝謝, 克里斯
感謝克勞迪奧,我編輯了問題,以顯示出答覆出OAuth 2.0 Playground – user1501783 2012-08-10 03:25:48
你也可以添加請求嗎?隨意刪除敏感細節 – 2012-08-10 03:34:52
我不知道如何顯示實際請求,除了上面首先列出的失敗行之外:credentials = flow.step2_exchange(authorization_code)。我假設'流'是在其中一個導入中定義的:從oauth2client.client導入FlowExchangeError。來自oauth2client.client的 導入AccessTokenRefreshError。來自oauth2client.client的 import Credentials ...你能告訴我如何看到發送的實際請求嗎? – user1501783 2012-08-10 03:43:13