Cannot access Google Ads API using service account: Oauth token HTTP header is malformed

47 views
Skip to first unread message

Farhan Husain

unread,
Mar 5, 2025, 7:32:40 PM3/5/25
to Google Ads API and AdWords API Forum
Hi,

We need access to our Google Ads accounts through API and have been trying to follow the instructions shown here: https://developers.google.com/google-ads/api/docs/get-started/introduction

We are using the Service Account workflow (as that is what is recommended in the documentation). However, no matter what we do we keep getting stuck with an error of "Oauth token HTTP header is malformed". This error occurs with both the REST example and the Python example. We are trying this on our test manager and test account setup, so that it doesn't cause issues with our live account.

The error is vague and doesn't tell us what exactly is wrong with the header or how to resolve it. We are able to acquire an access token without any issues when using the REST example. On the Python example, there doesn't seem to be any intermediate step to acquire an access token (presumably because it is encapsulated within the Python function call).

Any help would be greatly appreciated as the documentation and errors are not very helpful.

Thanks


Google Ads API Forum Advisor

unread,
Mar 5, 2025, 11:16:59 PM3/5/25
to far...@futureproof.am, adwor...@googlegroups.com

Hi,

Thank you for contacting the Google Ads API support team.

After reviewing your concern, I understand that you are getting the "OAUTH_TOKEN_HEADER_INVALID" error. It appears that the credentials sent in your HTTP request are not valid, and this is why you have encountered this error. To address this issue, ensure that you have provided the accurate access token linked to your account. To resolve this issue, you should use an access token generated using the same Google Ads account that is associated with the developer token you are using in your request. In other words, the developer token and the access token should be from the same Google Ads account to ensure proper authorization and I highly recommend you to add the correct developer token copied from the API center of your Ads UI and see if it fixes the issue.

Also, follow the Prerequisites for service accounts and OAuth Service Account Flow as per your client library. If the issue remains the same, kindly get back to us so that we can investigate the issue further.
 

Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5
[2025-03-06 04:16:07Z GMT] This message is in relation to case "ref:!00D1U01174p.!5004Q02vH6Wv:ref" (ADR-00291806)



Reply all
Reply to author
Forward
0 new messages