我試圖在OAuth 1.0和2.0版本中訪問Google的API,在兩種情況下,我需要在值爲'OAuth'的標頭中填充授權字段,然後是訪問令牌。我嘗試了以下方法,但Google向我發出一個錯誤,指出Authorization標頭值存在問題。我使用Python的龍捲風如何在OAuth 2.0中使用Google API傳遞「授權」標頭值
additional_headers = {
"Authorization": "OAuth "+GoogleOAuth2Mixin.access_token,
"Accept-Encoding": None
}
h = httputil.HTTPHeaders()
h.parse_line("Authorization: OAuth "+GoogleOAuth2Mixin.access_token)
request = httpclient.HTTPRequest(self._USER_INFO_URL+"?access_token="+GoogleOAuth2Mixin.access_token, method="GET", headers=h)
self.httpclient_instance.fetch(
request,
self.async_callback(callback)
)
我試着用這兩種方法,通過傳球頭球「H」和「additional_headers」,但它不工作。什麼是準確的方法?
你得到了什麼確切的錯誤? – Drahkar 2012-02-04 22:34:36
這是錯誤我看到: { 「錯誤」:{ 「錯誤」:[{ 「域」: 「com.google.auth」, 「原因」: 「invalidAuthentication」, 「消息「: 「無效的標記」, 「的locationType」: 「首標」, 「位置」: 「授權」 } ], 「代碼」:401, 「消息」: 「無效的標記」 } } – 2012-02-04 22:45:35
我在成功驗證後發現此錯誤 - https://www.googleapis.com/oauth2/v1/tokeninfo – 2012-02-04 22:49:50