Google OAuth 2:令牌请求中出现response_type错误 [英] Google OAuth 2: response_type error on token request

查看:1846
本文介绍了Google OAuth 2:令牌请求中出现response_type错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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


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


请求详细信息:

 范围= 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错误请求
Cache-Control:no-cache ,no-store,max-age = 0,必须重新验证
Pragma:no-cache
过期时间:1990年1月1日星期五00:00:00 GMT
日期:7月27日星期五2012 22:44:35 GMT
内容类型:application / json
X-Content-Type-Options:nosniff
X-Frame-Options:SAMEORIGIN
X-XSS-保护:1; mode = block
服务器:GSE

{
错误:invalid_request
}
$ b $ h2>编辑2

删除 response_type 并更改像上面的URL解决了这一点。

解决方案

在收到授权码后,您必须向访问令牌询问'/ o / oauth2 / token'。该请求不采用'作用域',也没有'response_type'参数。有关更多详细信息,请参阅 Google文档


I am trying to return an OAuth 2 response code for an OAuth response token. However, my request returns the following error which has zero results in google. I tried changing response_type to "token" instead of "code" but that didn't work either.

OAuth 2 parameters can only have a single value: response_type

Request Details:

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=_____

I'm sending this second-step payload to POST https://accounts.google.com/o/oauth2/auth

What is wrong with my request?

Edit

I just realized that there is the https://accounts.google.com/o/oauth2/token URL that should be used for this request. However, changing to that URL now gives:

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"
}

Edit 2

Removing the response_type and changing the URL like above solved this.

解决方案

After receiving the authorization code you have to ask '/o/oauth2/token' for the access token. This request takes no 'scope' and no 'response_type' parameters. See the Google documentation for more details.

这篇关于Google OAuth 2:令牌请求中出现response_type错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆