简体   繁体   English

无法检索Google Oauth2的刷新令牌

[英]Cannot retrieve refresh token for google Oauth2

Im using the following code in php to retreive the access token: 我在PHP中使用以下代码检索访问令牌:

  $url ="https://accounts.google.com/o/oauth2/token";
$fields = array(
   "client_id"=>"{your client id}",
   "client_secret"=>"{your client secret}",
   "refresh_token"=>"{your refresh token 1/.....}",
   "grant_type"=>"refresh_token"
);

$ch = curl_init($url);

//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_POST,count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

//execute post
$lResponse_json = curl_exec($ch);

//close connection
curl_close($ch);

The problem is im receiving the following error: 问题是即时消息收到以下错误:

"error" : "invalid_client", "error_description" : "The OAuth client was not found." “”错误“:” invalid_client“,”错误_说明“:”找不到OAuth客户端。“

I have tried de-authenticating the app etc still to no avail. 我尝试取消验证应用程序等仍然无济于事。 Can anyone help? 有人可以帮忙吗?

The problem was that i was not enclosing the client_id etc... within " " in the array. 问题是我没有将client_id等封闭在数组中的“”内。 Curl was not sending the request properly. Curl没有正确发送请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM