Open gmehta1996 opened 1 year ago
Hi, I have same error, did you find the solution ?
@gmehta1996 @muratarchon it seems that you can only use this API using OAuth, not API keys.
Here: https://developers.google.com/adsense/management/reference/rest/v2/accounts/list When you try the API on the right, and only set API keys, you'll have an error:
"message": "API keys are not supported by this API. Expected OAuth2 access token or other authentication credentials that assert a principal. See https://cloud.google.com/docs/authentication",
So we have to use OAuth2, as in the examples: https://github.com/googleads/googleads-adsense-examples/blob/9f1b24bbfdecf418ee48ce18bc3422aef835a138/v2/php/adsense-sample.php#L114C13-L114C38 (PHP).
It's misleading as the client_id and client_secret are used, but not as API keys: it's for OAuth security.
Hi I'm trying to fetch the ad unit details of an Adsense Account using the Adsense Management API. I created the application on google cloud console and got the client_id and client_secret which I used to get the refresh token as well.
I used the following code snippet to get account id and name:
And I was able to get the account name and Id using this , then I further tried to get the ad unit details but I'm getting the mentioned error:
The code snippet I'm using here is:
Here I'm using the publisher id of the account in the variable - accountId and the customer id in the variable - adClientId.
Am I using the correct IDs? if not from where do I find the ids. If the ids being used are correct then I'm getting this permission error stated above
I have added these scopes as well
Also I tried the same in the APIs Explorer UI and got the same result
{ "error": { "code": 403, "message": "The caller does not have permission", "status": "PERMISSION_DENIED" } }
What permission do I require here or what can be the solution to get the ad units details for Adsense. I would really appreciate the help as I'm stuck since many days.