Google Apis Oauth1到Oauth2迁移:令牌无效或我们无法对其进行解码

时间:2014-11-17 10:40:04

标签: php curl oauth google-oauth

我写了一个PHP脚本,使用Curl从oauth1迁移到oauth2,标题是正确的,表单数据也是正确的,但响应始终是:

{
 ["error"]=>
   string(13) "invalid_token"
 ["error_description"]=>
   string(54) "Either the token is invalid or we could not decode it."
}

这是Curl的动词:

  

POST / o / oauth2 / token HTTP / 1.1   主持人:accounts.google.com   接受: /   授权:OAuth oauth_consumer_key =“mykey.com”,oauth_nonce =“1416228848”,oauth_signature_method =“HMAC-SHA1”,oauth_token =“1%252FNZL27URrdQlwLe”,oauth_timestamp =“1416228848”,oauth_version =“1.0”,oauth_signature =“qcX5MW% 2BuXUXsUyz7j7x8"   内容长度:230   内容类型:application / x-www-form-urlencoded

 * upload completely sent off: 230 out of 230 bytes
 < HTTP/1.1 400 Bad Request

postfields包含oauth2数据:

 $params = [
  "grant_type"             => "urn:ietf:params:oauth:grant-type:migration:oauth1",
  "client_id"              => $oauth2_client_id,
  "client_secret"          => $oauth2_client_secret,
  "scope"                  => "https://mail.google.com"
 ];
 $postData=http_build_query($params, '', '&');

我在多个令牌上尝试了它并返回相同的消息!

0 个答案:

没有答案