Google Cloud SDK-自动化gcloud身份验证登录网络流程

act*_*ner 1 authentication automation remote-server google-oauth gcloud

安装google cloud sdk后,当我运行“ gcloud auth login”时,它为我提供了一个链接,用于将粘贴复制到浏览器中以获得新的凭据并验证我的帐户。

但是,我想在远程计算机上设置和使用gcloud,在该计算机上,用户将无法复制粘贴浏览器中生成的链接并将生成的验证码粘贴回终端。如何在没有用户干预的情况下自动执行此操作?

我的帐户是最终用户帐户,即不是服务帐户。

还有其他替代方法,可以使用生成的链接对我的帐户进行预身份验证,以在本地计算机上的浏览器中使用,然后在远程计算机上使用相同的配置吗?

提前致谢!

根据Vilas的评论进行更新:

我很确定我使用的是正确的json密钥文件,因为从google开发者控制台下载后,我没有修改名称/内容。我尝试从上述命令中删除account@gmail.com。但是仍然出现相同的错误

ERROR: (gcloud.auth.activate-service-account) The .json key file is not in a valid format. Your current active account [account@gmail.com] does not have any valid credentials.Please run:

  $ gcloud auth login

to obtain new credentials, or if you have already logged in with a
different account:

  $ gcloud config set account ACCOUNT

to select an already authenticated account to use.

Your current active account [account@company.com] does not have any valid credentials
Please run:

  $ gcloud auth login

to obtain new credentials, or if you have already logged in with a
different account:

  $ gcloud config set account ACCOUNT

to select an already authenticated account to use.
Run Code Online (Sandbox Code Playgroud)

小智 5

快速检查一下您是否拥有正确的--key-file .json文件:它必须包含client_email字段/属性。