Request had invalid credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential.

35,924 views
Skip to first unread message

app factory

unread,
Jul 9, 2019, 10:13:42 AM7/9/19
to Google Cloud Developers

To create service account from our web application, using below URL:

Access token generated using Oauth 2 and appended as part of URL parameters.


In this forumit is mentioned as access token can be passed either as part of authorization headers or URL parameters as below:


You can test these commands with the curl command-line application. Here's an example that uses the HTTP header option (preferred):

curl -H "Authorization: Bearer <access_token>" https://www.googleapis.com/drive/v2/files

Or, alternatively, the query string parameter option:

curl https://www.googleapis.com/drive/v2/files?access_token=<access_token>

We are passing access token as part URL parameters. Suddenly Its stopped working from last 5 days and receiving the below error.

Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

Is this URL with access token as parameter support stopped working from Google? Please let us know.

Thanks,
Guna

Bruno (Google Cloud Support)

unread,
Jul 11, 2019, 1:20:50 PM7/11/19
to Google Cloud Developers
Hello, 

If everything worked fine for the last 5 days I would like to ask if you tried to generate another <access_token> for your service account? 
From this documentation [1] under step 4 of the Basic steps “Refresh the access token, if necessary”, the token has a limited lifetime. 

app factory

unread,
Jul 12, 2019, 9:43:47 AM7/12/19
to Google Cloud Developers
Thanks for the reply, Bruno.

The same access token, when we passed as Authorization header, it is working and able to create service account. When passed as URL parameter, it is not working. Return the error as mentioned below:
Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. Seehttps://developers.google.com/identity/sign-in/web/devconsole-project.

Sami Islam

unread,
Jul 13, 2019, 7:22:23 PM7/13/19
to Google Cloud Developers
Hello,

There is a possibility that the Application Default Credentials are not available. Can you try login by running the following command:

gcloud auth application-default login


After that, please check the page for further reference.

In order to make sure that the authentication process went accordingly, please run:

gcloud auth application-default print-access-token

You should be able to see an access token. Please check the following page for reference. 
 
Also I am providing relevant stackoverflow threads that addresses this issue (1, 2, 3) so that it helps you in understanding this issue and provides additional steps. If none of those solutions worked for you, please post the issue on Public Issuetracker thread so that we can verify whether this issue is indeed on our end. Please note that Google Group is specifically used for general Google Products and services discussion. For further troubleshooting as mentioned, you could use Public Issuetracker thread and third party community service such as Stackoverflow to help you with this issue.
Reply all
Reply to author
Forward
0 new messages