gpt4 book ai didi

javascript - 错误: 7 PERMISSION_DENIED: Your application has authenticated using end user credentials from the Google Cloud SDK

转载 作者:行者123 更新时间:2023-12-01 00:14:39 25 4
gpt4 key购买 nike

几个月前,这在我的 websocket 服务器内部没有代码更改的情况下工作,但是今天使用它,似乎 Google 语音到文本 api 不再允许使用访问 token 进行身份验证。

这是我以前的工作方法,直到今天遇到这个错误

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.

任何解决此问题的帮助将不胜感激!

最佳答案

我通过执行以下操作解决了环境问题和随后的错误:

const options = {
keyFilename: 'path-to-key.json',
projectId: 'project-name',
};

const client = new speech.SpeechClient(options);

关于javascript - 错误: 7 PERMISSION_DENIED: Your application has authenticated using end user credentials from the Google Cloud SDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59850814/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com