谷歌oauth1到oauth2迁移invalid_token错误

时间:2014-01-08 08:50:29

标签: google-oauth oauth2-playground

我一直在尝试使用oauth1访问令牌获取新的oauth2刷新令牌,但它不断返回" invalid_token"错误。我检查过并且访问令牌正常工作。我也在oauth2操场上测试了相同的信用/参数,结果是一样的。任何帮助表示赞赏...

这是curl详细输出:

> POST /o/oauth2/token HTTP/1.1
Host: accounts.google.com
Content-Type: application/x-www-form-urlencoded
Authorization: OAuth oauth_nonce="cb7407355fe20f509cb6bf901eae2d24", oauth_timestamp="1389169471", oauth_consumer_key="***", oauth_token="1%2FFVy....", oauth_signature_method="HMAC-SHA1", oauth_signature="0YL1hH5R571nOH1byeHxQlg%2Fa6g%3D"
Content-Length: 444

* upload completely sent off: 444 out of 444 bytes
< HTTP/1.1 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: Wed, 08 Jan 2014 08:24:31 GMT
< Content-Type: application/json
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
* Server GSE is not blacklisted
< Server: GSE
< Alternate-Protocol: 443:quic
< Transfer-Encoding: chunked
< 
* Connection #0 to host accounts.google.com left intact
string(415) "HTTP/1.1 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: Wed, 08 Jan 2014 08:24:31 GMT
Content-Type: application/json
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Alternate-Protocol: 443:quic
Transfer-Encoding: chunked

{
  "error" : "invalid_token"
}"

2 个答案:

答案 0 :(得分:1)

你能检查一下你是否将{}中的client_secret放在POST Body中吗?

grant_type =瓮:IETF:PARAMS:OAuth的:授予型:迁移:您好!OAuth1&安培; CLIENT_ID = xxxxxxx.apps.googleusercontent.com&安培; client_secret = <强> {XXXXXXX}

生成oauth_signature时,您还需要在client_secret值周围放置{}

答案 1 :(得分:0)

我们对OAuth1-&gt; OAuth2令牌迁移的验证部分进行了一些更改。您是否介意再次检查迁移流程并使用结果更新此线程?