Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential

336 views
Skip to first unread message

ads dm

unread,
Dec 20, 2023, 12:06:24 PM12/20/23
to Google Ads API and AdWords API Forum
Hello, today when the scheduled task was running the interface, the following error message was prompted.
[
    {
        "error": {
            "code"401,
            "message""Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
            "status""UNAUTHENTICATED",
            "details": [
                {
                    "@type""type.googleapis.com/google.ads.googleads.v14.errors.GoogleAdsFailure",
                    "errors": [
                        {
                            "errorCode": {
                                "authenticationError""OAUTH_TOKEN_HEADER_INVALID"
                            },
                            "message""Oauth token HTTP header is malformed."
                        }
                    ],
                    "requestId""6x5jlus6v_8O4Z1yZKeBVw"
                }
            ]
        }
    }
]
Snipaste_2023-12-20_18-21-58.png
Yesterday, the interface could still obtain data normally.

Google Ads API Forum Advisor

unread,
Dec 20, 2023, 12:14:37 PM12/20/23
to ads.eco...@gmail.com, adwor...@googlegroups.com

Hi,

Thank you for reaching out to the Google Ads API support team.

After reviewing your query, I understand that you are getting the error "OAUTH_TOKEN_HEADER_INVALID" in the production environment.

It appears that the credentials sent in your HTTP request are not valid and this is why you have encountered this error. The prevention tip recommended is to make sure you've passed the correct access token associated with your account. It's sometimes confused with refresh tokens and authorization codes. If you would like to get a credential that can access all client accounts under a manager account, make sure you get the refresh token for the manager account. For more details, see our guide on access token and refresh token and OAuth2.

If the issue still persists, please provide us with the complete API logs (request and response with request-id and request header) generated at your end to better assist you.
If you are using a client library and haven't enabled the logging yet, I would request you to enable logging for the specific client library that you are using. You can refer to the guides Java, .Net, PHP, Python, Ruby or Perl to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag.

You can send the details via Reply privately to the author option, or direct private reply to this email.

This message is in relation to case "ref:!00D1U01174p.!5004Q02r2twx:ref"

Thanks,
 
Google Logo Google Ads API Team


ads dm

unread,
Dec 21, 2023, 1:43:49 AM12/21/23
to Google Ads API and AdWords API Forum
Thank you for your reply. We have found the cause of the problem. A colleague reset the developer token, causing the original token to become invalid. After replacing it with the new developer token interface, the interface runs normally.
Reply all
Reply to author
Forward
0 new messages