我已经按照谷歌云语音api快速启动请求api使用
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
并跟随 link,但我得到了错误
{
"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 login
如果要确保身份验证过程顺利进行,请运行:
gcloud auth application-default print-access-token
你应该看到一个访问令牌,参考gcloud auth application-default print-access-token
将$(gcloud auth application-default print-access-token)
替换为调用命令时打印的内容。
我通过注销修复了问题,并登录以同意google自上次使用谷歌云(我的情况下是firebase)以来所做的一些新条款和条件。