请求的身份验证凭据无效.云语音 api 中的预期 OAuth 2 访问令牌错误 [英] Request had invalid authentication credentials. Expected OAuth 2 access token error in cloud speech api

查看:31
本文介绍了请求的身份验证凭据无效.云语音 api 中的预期 OAuth 2 访问令牌错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经按照谷歌云语音 api 快速入门来使用请求 api

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

我现在该怎么办?

提前谢谢

推荐答案

可能是应用程序默认凭据不可用

尝试通过运行登录

gcloud auth application-default login

并按照说明操作,参考:gcloud auth application-default登录

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

您应该看到一个访问令牌,参考 gcloud auth 应用程序默认打印访问令牌

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

这篇关于请求的身份验证凭据无效.云语音 api 中的预期 OAuth 2 访问令牌错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆