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

10,058 views
Skip to first unread message

Haik

unread,
Jun 19, 2019, 6:18:14 AM6/19/19
to AdWords API and Google Ads API Forum
We have our app working with our development MCC keys and all works fine.

The problem is when we try to switch to the new production keys, we get an Expected OAuth 2 access token error.
  
Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential.


The only thing I do is change the app config keys:

<add key="DeveloperToken" value="XXX" />
<add key="LoginCustomerId" value="XXX" />
<add key="OAuth2Mode" value="APPLICATION"/>
<add key="OAuth2ClientId" value="XXX.apps.googleusercontent.com"/>
<add key="OAuth2ClientSecret" value="XXX"/>
<add key="OAuth2RefreshToken" value="XXX"/>


As I said before, the application works fine with the old keys, but does not work with the new keys.

To generate the new refresh token I used the https://github.com/googleads/googleads-dotnet-lib/wiki/Using-OAuthTokenGenerator software.


Google Ads API Forum Advisor Prod

unread,
Jun 19, 2019, 1:51:24 PM6/19/19
to adwor...@googlegroups.com
Hello Haik

You will be able to validate your credentials by using the OAuth doctor. The tool will help determine if your OAuth2 credentials are correctly configured and ready to make API calls and guide you through fixing any OAuth2 problems it detects and verify the corrected configuration. Please give this a try and let us know if you have any issues.

Regards,
Sai Teja, Google Ads API Team

ref:_00D1U1174p._5001UBoARK:ref

Haik

unread,
Jun 26, 2019, 8:50:12 AM6/26/19
to AdWords API and Google Ads API Forum
I run the OAuth tool but it does not help in any way.
I get the following error - ERROR: OAuth test failed.

Google Ads API Forum Advisor Prod

unread,
Jun 26, 2019, 11:13:54 AM6/26/19
to adwor...@googlegroups.com
Hello Haik,

To verify that your credentials are correct, you could try the CURL request provided below and see if you are able to generate the access token. If your credentials are correct, you should be able to generate an access token for the below CURL request.

curl https://www.googleapis.com/oauth2/v4/token \
-d refresh_token=your-refresh_token \
-d client_id=your-client-id \
-d client_secret=your-client-secret \
-d grant_type=refresh_token

If your credentials are incorrect or still facing issue then you could try generating a new refresh token with the help of this guide and retry your request. Please let me know if the issue persists.

Regards,
Sai Teja, AdWords API Team

ref:_00D1U1174p._5001UBoARK:ref

Haik

unread,
Jun 26, 2019, 12:10:15 PM6/26/19
to AdWords API and Google Ads API Forum
Ran the curl, but again got a meaningless json

{
  "access_token": "ya29.GlszB59HETtP0sTg..........",
  "expires_in": 3600,
  "token_type": "Bearer"
}

The oauth doctor returns the folowing:


2019/06/26 19:02:44 Client library language: dotnet
2019/06/26 19:02:44 Google Ads API client library config file: C:\Users\USER\App.Config
2019/06/26 19:02:44 Config keys and values:
2019/06/26 19:02:44     ClientID = ******************* (hidden)
2019/06/26 19:02:44     ClientSecret = ******************* (hidden)
2019/06/26 19:02:44     DevToken = ******************* (hidden)
2019/06/26 19:02:44     RefreshToken = ******************* (hidden)
2019/06/26 19:02:44 Please enter a Google Ads account ID:
XXXXXXXXX
2019/06/26 19:03:00 JSON response error: 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.
2019/06/26 19:03:00 ERROR: The login email may not have access to the given account.
2019/06/26 19:03:00 Attempting to regenerate refresh token...
2019/06/26 19:03:00 Visit the URL for the auth dialog:





Google Ads API Forum Advisor Prod

unread,
Jun 26, 2019, 3:54:23 PM6/26/19
to adwor...@googlegroups.com
Hello Haik,

I see the CURL operation is succeeded, which means the credentials you used in the CURL operation are right. Could you please place those credentials in your configuration/properties files and retry the API request? If you are facing any error, please share the entire error log and the exact credentials you have used in the configuration/properties files without redacting using reply privately to the author option?

Regards,
Sai Teja, Google Ads API Team

ref:_00D1U1174p._5001UBoARK:ref

Haik

unread,
Jun 26, 2019, 4:05:49 PM6/26/19
to AdWords API and Google Ads API Forum
Hi,

Just tested the keys in the app.
This is the error:

{{ "errorCode": { "authenticationError": "NOT_ADS_USER" }, "message": "User in the cookie is not a valid Ads user." }}


Google Ads API Forum Advisor Prod

unread,
Jun 26, 2019, 4:47:11 PM6/26/19
to adwor...@googlegroups.com
Hello Haik,

The not_ads_user error usually occurs when the  login used to generate the access token is not associated with any Google Ads account. Please make sure the email address used to generate the OAuth credentials has a Google Ads account.

Haik

unread,
Jun 27, 2019, 5:27:11 AM6/27/19
to AdWords API and Google Ads API Forum
Thanks! associating the user with the account solved it.
Reply all
Reply to author
Forward
0 new messages