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

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

问题描述

我已遵循通过使用

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应用程序默认登录

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天全站免登陆