【发布时间】:2012-06-06 14:48:43
【问题描述】:
我知道 SO 中有很多类似的问题,但我尝试了这些解决方案几个小时,但它们对我不起作用。我总是收到{ "error" : "unauthorized_client" }"。我想以编程方式刷新我的访问令牌以使用 Youtube API。我已经获得了一个refreshtoken。
这是我想出的:
$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:在这里获取新令牌可以正常工作:code.google.com/oauthplayground
-
没有想法?我真的不知道它有什么问题......