[Python] Service account authentication fails

41 views
Skip to first unread message

jo...@switchedonmedia.com.au

unread,
Jun 23, 2017, 5:43:23 AM6/23/17
to AdWords API Forum
Hi!

My goal is to pull a simple video performance report as per the following:

 #!/usr/bin/python3
  
   import settings
   from googleads import adwords
   from googleads import oauth2
  
   oauth2_client=oauth2.GoogleServiceAccountClient(oauth2.GetAPIScope("adwords"),
           client_email=None,
           key_file="privkey.json")
 
  adwords_downloader=adwords.AdWordsClient(settings.DEVELOPER_TOKEN,
          oauth2_client).GetReportDownloader()
 
  adwords_downloader.DownloadReportAsStringWithAwql("SELECT CustomerDescriptiveName,ExternalCustomerId,CampaignName,CampaignId,AdGroupName,AdGroupId,VideoTitle,VideoId,Im
    pressions,VideoViews,Clicks,Cost,Conversions FROM VIDEO_PERFORMANCE_REPORT DURING 20170621","CSV",client_customer_id="<one of our client ids>")

And then process it.

But when i run this, I keep getting a "NOT_ADS_USER" error message.

- I have created a service account in the API console
- The json private key file for the service account is located in 'privkey.json'
- We have a valid developer token for our MCC, which I've checked and double-checked

What is wrong?

Sreelakshmi Sasidharan (AdWords API Team)

unread,
Jun 23, 2017, 3:02:12 PM6/23/17
to AdWords API Forum
Hi John, 

The error NOT_ADS_USER means that the credentials used for authorizing the API call do not belong to a user who has an AdWords account. Could you confirm if you followed all the steps listed in the guide? Also, note that you need to specify the service account email id and the actual path to the key file as described in this guide. 

Is there a specific reason why you are trying to use the OAuth setup using service accounts? We recommend this approach only if you need domain specific features like impersonation. In all other cases we strongly recommend using installed app or web flows. If you are concerned about manually accepting the prompt while setting up OAuth, please note that it is a one time operation. Once the prompt is accepted, no manual intervention is required. By saving the refresh token, you can make your code renew the access token for every subsequent API calls.

Thanks,
Sreelakshmi, AdWords API Team
Reply all
Reply to author
Forward
0 new messages