【发布时间】:2020-01-23 01:04:06
【问题描述】:
几个月前这在我的 websocket 服务器内部没有代码更改的情况下工作,但是今天使用它似乎 Google 语音到文本 api 不再允许使用访问令牌进行身份验证。
这是我以前的工作方法,直到我今天遇到这个错误
const client = new speech.SpeechClient({
access_token: ACCESS_TOKEN,
projectId: 'project-name'
});
这让我在标题中出现了上述错误。
我还尝试通过如下设置环境来切换到服务帐户(我过去使用过)
export GOOGLE_APPLICATION_CREDENTIALS="path-to-key.json"
然后我在没有上述代码的情况下运行客户端,而是运行:
const client = new speech.SpeechClient();
这反而给我带来了这个美丽的错误,即使此时环境是使用项目 ID 设置的
Error: Unable to detect a Project Id in the current environment.
任何帮助解决此问题将不胜感激!
【问题讨论】:
标签: javascript sockets oauth gcloud google-speech-api