Ok so I get an access token and a Refresh token
I am writing the code so my server can get a new access token if it
expires (terrible for Server to Server but I guess google doesnt think
so)
$data = array(
'client_id' => '
XXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com',
'client_secret' => 'XXXXXXXXXXXXXXXXXXX',
'refresh_token' => 'XXXXXXXXXXXXXXXXXXX',
'grant_type' => 'refresh_token'
);
$ch = curl_init("
https://accounts.google.com/o/oauth2/token");
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
$resp = curl_exec($ch);
print_r(json_decode($resp));
RESULT:
[error] => invalid_grant
Scopes were
'
https://www.googleapis.com/auth/adsense',
'
https://www.googleapis.com/auth/adsense.readonly',
The structure is right out of the Documentation. Is there anyone here
that has managed to access the AdSense Management API with PHP without
using a web app i.e Server to Server with OAuth2 ??? I can do it all
day long with Twitter but for some reason but google's version seems
be all sorts of difficult.
Thx
Eric