简体   繁体   中英

Google Cloud SDK - Automate gcloud auth login web flow

After I install google cloud sdk, when I run ' gcloud auth login ', it provides me a link to copy paste into my browser to obtain new credentials and authenticate my account.

However, I want to setup and use gcloud on a remote machine where a user will not be available to copy paste the link generated in the browser and paste the resultant verification code back into the terminal. How do I automate this without user intervention?

My account is an end user account ie not a service account.

Is there any other alternative to do this whereby I can pre-authenticate my account using the generated link to use in the browser on my local machine and then use the same configuration on the remote machine?

Thanks in advance!

Update based on Vilas's comments:

I am pretty sure I am using the right json key file because I am not modifying the name/contents after downloading it from the google developers console. I tried removing account@gmail.com from the above command. But still getting the same error

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.

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

我只是遇到了同样的问题,密钥没有显示任何电子邮件地址,因此我在开发人员控制台中为该服务帐户生成了一个新密钥,并使用电子邮件地址创建了该密钥。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM