Hy,
I'm trying to access google adsense data.
Authentication is with Service Accounts... and it works but after that it seams that I cannot retrieve anything from my google adsense account
here is the code that I used:
putenv('GOOGLE_APPLICATION_CREDENTIALS='.__DIR__.'/../../../../'.'service-account-key.json');
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->setScopes([
'https://www.googleapis.com/auth/adsense',
'https://www.googleapis.com/auth/adsense.readonly'
]);
$service = new \Google_Service_AdSense($client);
$service->accounts->listAccounts();
And the response is :
{ "error": { "errors": [ { "domain": "global", "reason": "noAdSenseAccount", "message": "User does not have an AdSense account." } ], "code": 403, "message": "User does not have an AdSense account." } }
I am facing similar issue. Did you find anything ?
Unfortunately I think that Authentication with Service Accounts is NOT available for adsense api,
BUT I used the oauth authentication and saved the temporary token into a file on server (try to save it somewhere that is pretty safe) and each time my cron job try to connect to google adsense api, I'm using this saved token (user action is no longer needed as it was in the first time when the token doesn't exist yet). Even if this token is a temporary one, you can refresh it each time you want.
So do not spend any time trying to implement service accounts as authentication for adsense api.
you have to deactivate ad blocker
When I wanted to activate Google Ads API I just turn off AdBlock for all sites and It have worked!
It looks like the original issue here has been resolved.
Thanks everybody for the ad blocker tips. It seems that people are landing here and finding it helpful.
What is ad blocker ? where to deactivate it ?
@vazgen It's just a chrome extension. So if you added it you have to turn it off.
Google it! :)
Most helpful comment
you have to deactivate ad blocker