Request had invalid authentication credentials. Expected OAuth 2 access token error in cloud speech API

17,538 views
Skip to first unread message

Div Patel

unread,
Feb 10, 2018, 12:01:51 PM2/10/18
to Google Cloud Developers
i have follow the google cloud speech api quickstart of requesting api by using <code>curl -s -H "Content-Type: application/json" \ -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \ https://speech.googleapis.com/v1/speech:recognize \ -d @sync-request.json</code> and following <a href="https://cloud.google.com/speech/docs/quickstart"> link</a> but i got error of <code>{
  "error": {
    "code": 401,
    "message": "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.",
    "status": "UNAUTHENTICATED"
  }
}</code> what should i do now...thanx in advance

George (Cloud Platform Support)

unread,
Feb 10, 2018, 5:48:32 PM2/10/18
to google-c...@googlegroups.com
Hello DivYesh, 

The tutorial you follow require you to enable the Cloud Speech API for your project, create a service account, and download a private key as JSON. The service account is most important in this case, as the error seems to point to invalid credentials. How did you follow these steps, exactly? What were the results for each of the steps? Have you followed all these steps without any errors? No problems of any kind? 

You can read more detail on the "Creating and Managing Service Accounts" documentation page

If you need to send confidential or private information, you may securely do so by using the drop-down list of the "reply" button at the top right of the editing window, and send me a private message. 

Roger Whipp

unread,
May 30, 2018, 2:47:13 PM5/30/18
to Google Cloud Developers
I am having exactly the same problem. I have followed the steps exactly as written but I must have missed something. Any help appreciated.

Roger Whipp

unread,
May 31, 2018, 8:56:36 AM5/31/18
to Google Cloud Developers


El miércoles, 30 de mayo de 2018, 20:47:13 (UTC+2), Roger Whipp escribió:
I am having exactly the same problem. I have followed the steps exactly as written but I must have missed something. Any help appreciated.


SOLUTION:

curl -s -H "Content-Type: application/json" -H "Authorization: Bearer "YOUR-ACCESS-TOKEN https://speech.googleapis.com/v1/speech:recognize -d @sync-request.json

Altanai Bisht

unread,
Oct 22, 2018, 9:26:17 AM10/22/18
to Google Cloud Developers
Adding bearer solved my issue , II was earlier trying with username and pass as client id and secret which was yielding "Requests from referer <empty> are blocked." or "
Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. " . Thank you Roger Whipp

George (Cloud Platform Support)

unread,
Oct 22, 2018, 12:28:44 PM10/22/18
to Google Cloud Developers
Hi DivYesh, 

Is your GOOGLE_APPLICATION_CREDENTIALS environment variable set? It may be worthwhile running the command with the actual token, in place of $(gcloud auth application-default print-access-token), to compare results. 

Maddipatala Yugandhar

unread,
Mar 19, 2019, 6:29:49 PM3/19/19
to Google Cloud Developers
Hi Google Team,

I had already pasted error messages . Kindly advance .

George (Cloud Platform Support)

unread,
Apr 5, 2019, 12:32:25 PM4/5/19
to Google Cloud Developers
Hello Maddipatala, 

It is not clear where you pasted error messages, and what error messages you refer to. How do these error messages related to Speech API quick start? If this is a new issue, opening a new, dedicated thread should prove more effective. 

app factory

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

Getting the same error when trying to create service account using below api:

It was working until last week. But now getting this 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.

Support to pass access token as part of URL parameter stopped working?

Thanks,
Guna
Reply all
Reply to author
Forward
0 new messages