You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
service = discovery.build('adsense', 'v2', credentials = credentials)
# Retrieve account list in pages and display data as we receive it.
request = service.accounts().list(pageSize=50)
# while request is not None:
result = request.execute()
print(result)
accounts = result['accounts']
for account in accounts:
print ('Account with ID "%s" and name "%s" was found. '
% (account['name'], account['displayName']))
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:
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://adsense.googleapis.com/v2/accounts/{account_id}/adclients/{adclient_id}/adunits?pageSize=50&alt=json returned "The caller does not have permission". Details: "The caller does not have permission">
The code snippet I'm using here is:
request = service.accounts().adclients().adunits().list(
parent=f"accounts/{accountId}/adclients/{adClientId}", pageSize=50)
result = request.execute()
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
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.
The text was updated successfully, but these errors were encountered:
"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",
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.
The text was updated successfully, but these errors were encountered: