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

11

我想返回OAuth响应令牌的OAuth 2响应代码。然而,我的请求返回以下错误,谷歌中没有任何结果。我尝试将response_type更改为"token"而不是"code",但也没有起作用。

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 进行此请求。然而,现在更改到该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并按上述更改URL解决了此问题。


2
该死,用智能手机打字太慢了 ;) - Jan Gerlinger
2个回答

5

在收到授权码后,您需要请求'/o/oauth2/token'来获取访问令牌。此请求不需要任何'scope'和'response_type'参数。有关更多详细信息,请参见Google文档


2

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接