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

孤街浪徒 提交于 2019-11-29 11:45:56

问题


i have followed the google cloud speech api quickstart of requesting api by using

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

and following link but i got error of

{
  "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"
  }
}

What should i do now?

Thanx in advance


回答1:


It could be that The Application Default Credentials are not available

Try to login by running

gcloud auth application-default login

And follow the instructions, reference: gcloud auth application-default login

If you want to make sure the authentication process went well, run:

gcloud auth application-default print-access-token

You should see an access token, reference gcloud auth application-default print-access-token




回答2:


Replace $(gcloud auth application-default print-access-token) with what gets printed when you call the command.




回答3:


I fixed the problem by logging out, and logging in to agree to some new terms and conditions google have made since last time I used google clouds (firebase in my case).



来源:https://stackoverflow.com/questions/48720306/request-had-invalid-authentication-credentials-expected-oauth-2-access-token-er

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!