我试图获取我需要在adsense主机api中使用的Access_token来授权我的请求,我有这样的代码
$curlHandle = curl_init();
$data = array(
'code' => 'AFC',
'client_id' => 'myClientId',
'client_secret'=> 'myClientSecret',
'redirect_uri' => 'http://smk.dev',
'grant_type'=>'authorization_code'
);
$url = 'https://accounts.google.com/o/oauth2/token';
curl_setopt($curlHandle,CURLOPT_URL,$url);
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlHandle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curlHandle, CURLOPT_POST, 1);
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $data);
curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($curlHandle);
$data = json_decode($result);
但我收到错误的回复" invalid_grant"我哪里错了?什么是代码参数?我使用google adsense host api中的参数
答案 0 :(得分:0)
这是一个多步骤的过程
看看这个(主要是第一张图片)https://developers.google.com/identity/protocols/OAuth2