无法检索 google Oauth2 的刷新令牌
Cannot retrieve refresh token for google Oauth2
我在 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);
问题是我收到以下错误:
"error" : "invalid_client",
"error_description" : "The OAuth client was not found."
我已经尝试取消对应用程序的验证等,但仍然无济于事。
有人可以帮忙吗?
问题是我没有将 client_id 等包含在数组的“”中。 Curl 未正确发送请求。
我在 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);
问题是我收到以下错误:
"error" : "invalid_client", "error_description" : "The OAuth client was not found."
我已经尝试取消对应用程序的验证等,但仍然无济于事。 有人可以帮忙吗?
问题是我没有将 client_id 等包含在数组的“”中。 Curl 未正确发送请求。