GOOGLE_APPLICATION_CREDENTIALS错误 [英] GOOGLE_APPLICATION_CREDENTIALS error
问题描述
我正尝试使用google语音API将音频文件转换为文本,但面临文档中的一些问题。我启用了语音API并创建了一个服务帐户文件。我还获得了激活的服务帐户凭据。然后,我编写了以下命令以使用我的服务帐户来检索授权令牌。
gcloud auth application-default打印访问令牌
但它会返回此消息
我不明白为什么会发生这种情况,因为我已经在计算引擎中创建了一个VM实例。任何人都可以解释我在哪里错了吗?此外,还有其他方法可以验证我的帐户并调用Google语音API吗?
解决方案 gcloud credentials and and application default credentials分开管理。如果您激活了服务帐户密钥文件,那么它只能用于gcloud命令,而不能用于应用程序默认凭证。
有几种方法可以激活应用程序默认凭据: copy 在windows上,这可能会有所不同,运行 获取到您的配置目录的路径。 像 应该有效。 I am trying to use the google speech API for converting an audio file to text, but facing some problems with the documentation.I have enabled the speech API and created an service account file. I also got the service account credentials activated. Then I wrote the following command to retrieve the authorization token using my service account. But it is returning this message
I don't understand why this is happening because I already have an VM instance created in my Compute Engine. Can anybody explain where am I going wrong with this? Also, is there any other way to authenticate my account and call the google speech API? gcloud credentials and and application default credentials are managed separately. If you activated service account key file this only can be used for gcloud commands but not for application default credentials. There a few ways to "activate" application default credentials: Use service account (preferred) copy On windows this might be different, run to get a path to your config directory. now command like should work. 这篇关于GOOGLE_APPLICATION_CREDENTIALS错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! gcloud auth application-default
一组命令仅用于管理应用程序默认值,并且与
gcloud auth
中的命令无关。
gcloud auth applocation-default login
或
GOOGLE_APPLICATION_CREDENTIALS =路径/到使用服务帐户(首选)
path / to / your / service_accont_key_file.json
to〜/ .config / gcloud / application_default_credentials.json`
gcloud info --format =值(config.paths.global_config_dir)
gcloud auth application-default print-access-token
gcloud auth application-default print-access-token
gcloud auth application-default
set of commands are there only to manage application default and having nothing to do with commands in gcloud auth
.
gcloud auth applocation-default login
, or
GOOGLE_APPLICATION_CREDENTIALS=path/to/your/service_accont_key_file.json
path/to/your/service_accont_key_file.json
to ~/.config/gcloud/application_default_credentials.json`
gcloud info --format="value(config.paths.global_config_dir)"
gcloud auth application-default print-access-token