Google ads API authentication errors

1,681 views
Skip to first unread message

Edmond Poon

unread,
Apr 1, 2022, 12:30:24 AM4/1/22
to Google Ads API and AdWords API Forum
I've been trying to follow the examples and documentation for the google ads API, but I haven't been able to complete a successful request. I currently have my developer token, client_id, client_secret, and refresh_token in my google ads YAML file, but I'm constantly getting authentication errors. Without adding any explicit scopes when generating the refresh token, I get the error below:

google.api_core.exceptions.PermissionDenied: 403 Request had insufficient authentication scopes. [reason: "ACCESS_TOKEN_SCOPE_INSUFFICIENT"  domain: "googleapis.com" metadata {key: "method" value: "google.ads.googleads.v9.services.GoogleAdsService.SearchStream'} 

metadata {key: "service" value: "googleads.googleapis.com"}].


I thought the issue was not explicitly adding the adwords scope for the SearchStream call, but generating a new refresh token with that scope gave me another error shown below:

google.auth.exceptions.RefreshError: ('unauthorized_client: Unauthorized', {'error': 'unauthorized_client', 'error_description': 'Unauthorized'}).


I'm pretty confident that I followed the documentation correctly, so I was wondering if anyone had any advice on how I could tackle this issue. If it helps, I'm getting the errors above when trying the get_campaigns.py example. Thanks!

Google Ads API Forum Advisor

unread,
Apr 1, 2022, 3:25:38 AM4/1/22
to edpo...@gmail.com, adwor...@googlegroups.com
Hi Edmon,

Thank you for reaching out to us.

Could you confirm if this guide is what you referred to when generating your credentials and refresh token when setting up your Python client library? In addition, when performing the step 3 of the guide and its #4 item, you need to ensure as well that you are logged in as the user / email address that was used to generate the cloud project and its credentials .

If the issue persists, could you provide the email address you used in generating the credentials via Reply privately to author?

Best regards,
Google Logo
Heidi
Google Ads API Team
 


ref:_00D1U1174p._5004Q2ZIjIe:ref

Edmond Poon

unread,
Apr 2, 2022, 1:49:33 PM4/2/22
to Google Ads API and AdWords API Forum
HI, thanks for the response. That guide was the guide I'm referring to. To double-check, is the email associated with the credentials of the email that was currently logged in at the time?

Google Ads API Forum Advisor

unread,
Apr 4, 2022, 6:31:17 AM4/4/22
to edpo...@gmail.com, adwor...@googlegroups.com

Hi Edmon,


Thanks for your response, I am also a member of the Google Ads API team and let me provide support to your concern.
 

Moving forward to your concern. When accessing the web browser for the URL to create the refresh token, you will need to be in a session using the same user / email address used to generate the client ID and client secret.


Let us know if you have any questions.
 

Regards,

Google Logo
Darwin
Google Ads API Team
 


ref:_00D1U1174p._5004Q2ZIjIe:ref
Reply all
Reply to author
Forward
0 new messages