使用刷新令牌生成访问令牌无效

时间:2018-11-17 13:08:10

标签: access-token php-curl refresh-token

授权过程后,我能够获得访问令牌refresh_token。访问令牌在1小时后到期,我知道这一点。因此,我尝试使用refresh_token获取新的access_token。我正在关注此链接here

我有此PHP CURL请求,但无法正常工作

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.googleapis.com/oauth2/v4/token?client_id=xxxxxxx&client_secret=xxxxxxx&refresh_token=xxxxxxxx&grant_type=refresh_token");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: www.googleapis.com', 'Content-Type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
$result = json_decode($result);
echo "<pre>";
print_r($result); //// This is blank

我在哪里犯错?我已经尝试调试了两个多小时,但仍然无法正常工作。有什么帮助吗?

0 个答案:

没有答案