【问题标题】:Google OAuth 2: response_type error on token requestGoogle OAuth 2:令牌请求上的 response_type 错误
【发布时间】:2012-07-26 15:31:30
【问题描述】:

我正在尝试为 OAuth 响应令牌返回 OAuth 2 响应代码。但是,我的请求返回以下错误,该错误在 google 中的结果为零。我尝试将 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 应该用于此请求。但是,现在更改为该 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 解决了这个问题。

【问题讨论】:

  • 该死,用智能手机打字太费时间了;)

标签: google-api oauth-2.0


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    收到授权码后,您必须向“/o/oauth2/token”询问访问令牌。此请求不接受“范围”和“响应类型”参数。有关详细信息,请参阅Google documentation

    【讨论】:

      猜你喜欢
      • 2013-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-28
      • 2019-01-21
      • 1970-01-01
      • 2012-11-06
      • 2018-12-28
      相关资源
      最近更新 更多