我知道这里有很多类似的问题,但我尝试了几个小时的这些解决方案,但他们没有为我工作。我总是得到一个{ "error" : "unauthorized_client" }"
。我想以编程方式刷新我的accesstoken以使用Youtube API。我已经获得了一个清晰的说法。来自PHP的Google身份验证
这是从来就想出:
$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
'client_secret' => '<mysecret>',
'grant_type' => 'refresh_token',
'refresh_token' => '<my_refresh_token>',
'client_id' => '<my_client_id>.apps.googleusercontent.com',
'redirect_url'=>'<my_redirect_uri>'
));
curl_setopt($ch, CURLOPT_URL, 'https://accounts.google.com/o/oauth2/token');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
echo var_dump(curl_exec($ch));
哪些错误呢?
PS:获取一个新的令牌在这里工作得很好:https://code.google.com/oauthplayground/ –
没有想法?我真的不知道它有什么问题...... –