- Permission Denied Error - 2 Updates
Kulvinder Tuteja <ascendeum.weblog@gmail.com>: Mar 17 01:16AM -0700 HI Adsense Team, Thank you I was able to create the script but I get the following error when trying to get adunits details: "The caller does not have permission". Details: "The caller does not have permission" service = discovery.build('adsense', 'v2', credentials = credentials) 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'])) # Retrieve the ad units for the provided ad client ID. request = service.accounts().adclients().adunits().list( parent=f"accounts/{accountId}/adclients/{adClientId}", pageSize=100) print(request) result = request.execute() Here I'm using the *publisher id* with the variable accountId and *customer id* with the variable adClientId but receiving "The caller does not have permission" error although the other service to get account details is working for me. I have the client_id, client_secret and refresh_token with me and able to use the other service i.e service.accounts().list(pageSize=50) For the ad unit details I also tried the APIs Explorer but getting the same error there as well: { "error": { "code": 403, "message": "The caller does not have permission", "status": "PERMISSION_DENIED" } } What permissions do I need to check here which are being denied. Kindly help On Tuesday, 7 March 2023 at 23:22:12 UTC+5:30 Ad Sense API wrote: Hi Kulvinder, Thanks for your email. There is a selection of sample code available at https://developers.google.com/adsense/management/libraries, including python examples. Hopefully something there will help. Regards, Andrew (AdSense API team) ref:_00D1U1174p._5004Q2jWz3m:ref |
Ad Sense API <adsenseapi@forumsupport.google>: Mar 17 02:46PM Hi Kulvinder, Great that you have made progress. I think the missing part is that you need to call service.accounts().adclients().list() with the parameter "accounts/{accountId}". Then you will have the correct value for the adclient to use as the parent for the call to service.accounts().adclients().adunits().list(). If you still hit problems, I would recommend experimenting with the API explorer (the "Try this method" box) on the management API documentation page at https://developers.google.com/adsense/management/reference/rest/v2/accounts/list Regards, Andrew (AdSense API team) ref:_00D1U1174p._5004Q2jWz3m:ref |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to adsense-api+unsubscribe@googlegroups.com. |
No comments:
Post a Comment