如何为Google Compute Engine设置GOOGLE_APPLICATION_CREDENTIALS? [英] How to set GOOGLE_APPLICATION_CREDENTIALS for Google Compute Engine?
问题描述
我有Google Compute Engine的凭据文件,重命名为key.json。下一步是将环境变量设置为GOOGLE_APPLICATION_CREDENTIALS。但是它显示错误:从环境变量GOOGLE_APPLICATION_CREDENTIALS ... path读取凭据文件时出错。从流中读取凭据时出错,未指定'type'字段。
I have Google Compute Engine's Credentials file , renamed as key.json. The next step is to set the environment variable with name GOOGLE_APPLICATION_CREDENTIALS. But it says error: Error reading credential file from environment variable GOOGLE_APPLICATION_CREDENTIALS ...path.. Error reading credentials from stream, 'type' field not specified.
httpTransport = GoogleNetHttpTransport.newTrustedTransport();
GoogleCredential credential = GoogleCredential.getApplicationDefault();
我想知道如何在日食中设置变量GOOGLE_APPLICATION_CREDENTIALS?
I want to know how to set variable GOOGLE_APPLICATION_CREDENTIALS in eclipse?
推荐答案
您收到此错误,因为您下载了OAuth 2.0客户端ID而不是服务帐户键。
You got the error because you downloaded an OAuth 2.0 Client ID instead of a Service Account key.
如果您要使用常规用户凭据作为应用程序默认设置,您现在可以使用 gcloud beta auth application-default login
命令启动Web登录流程。这样会将它们放在应用程序默认凭据的知名位置,因此,如果使用此方法,则应取消设置GOOGLE_APPLICATION_CREDENTIALS变量。
If you want to use regular user credentials as the application default, you can now use the gcloud beta auth application-default login
command to launch the web sign-in flow. This puts them in the well-known location for application default credentials, so you should unset the GOOGLE_APPLICATION_CREDENTIALS variable if you use this method.
这篇关于如何为Google Compute Engine设置GOOGLE_APPLICATION_CREDENTIALS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!