Php 无法检索google Oauth2的刷新令牌

Php 无法检索google Oauth2的刷新令牌,php,curl,google-api,Php,Curl,Google Api,Im使用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"=&

Im使用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);
问题是我收到以下错误:

“错误”:“无效的\u客户端”, “错误描述”:“未找到OAuth客户端。”

我已尝试对应用程序等进行身份验证,但仍然无效。
有人能帮忙吗?

问题是我没有附上客户id等。。。在数组中的“”内。Curl没有正确发送请求

您是否已检查是否输入了正确的客户端id?我想你的意思是检索访问令牌。您已经有了一个刷新令牌。您需要的是一个新的访问令牌。如果客户端id正确,这将检索访问令牌。我从这里得到了答案: