Google OAuth 2:令牌请求中的response_type错误

时间:2012-07-27 22:34:47

标签: google-api oauth-2.0

我正在尝试为OAuth响应令牌返回OAuth 2响应代码。但是,我的请求返回以下错误,谷歌的结果为零。我尝试将response_type更改为“令牌”而不是“代码”,但这也无效。

  

OAuth 2参数只能有一个值:response_type

请求详细信息:

scope=https://www.googleapis.com/auth/userinfo.email
client_secret=_____
response_type=code
grant_type=authorization_code
redirect_uri=http://localhost/folder/
client_id=____.apps.googleusercontent.com
code=_____

我将此第二步有效负载发送到POST https://accounts.google.com/o/oauth2/auth

我的请求有什么问题?

修改

我刚刚意识到应该为此请求使用https://accounts.google.com/o/oauth2/token网址。但是,现在更改为该URL会显示:

HTTP/1.0 400 Bad Request
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Date: Fri, 27 Jul 2012 22:44:35 GMT
Content-Type: application/json
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE

{
  "error" : "invalid_request"
}

编辑2

删除response_type并更改上述网址解决了这个问题。

2 个答案:

答案 0 :(得分:5)

收到授权代码后,您必须向'/ o / oauth2 / token'询问访问令牌。此请求不带“范围”且没有“response_type”参数。有关详细信息,请参阅Google documentation

答案 1 :(得分:2)

尝试了几种方法后,进行OAUTH2调用所需的参数是 redirect_uri,response_type,scope,client_id。我根据收到的错误报告继续调试oauth调用。

相关问题