Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Why do I have to complete 3 Cloud SDK sign-in steps every time I run "gcloud auth login"?

I don't have to do this for any other app I add to my account. Am I doing something wrong?

 

gcloud_1.png

gcloud_2.png

gcloud_3.png

2 4 385
4 REPLIES 4

Hi @robinkunde-ck 

Welcome to Google Cloud Community!

This is more likely a re-authorisation process if you are doing it on the Cloud Shell, since cloud shell are tied to ephemeral pre-configured vm.

I hope this information is helpful.

If you need further assistance, you can always file a ticket on our support team.

No this happens every time I run "gcloud auth login" in the terminal. I've asked around to see if it has something to do without we configured our enterprise account, but when I tried it on my personal Google Cloud account on my personal machine, I ran into the same issue.

Not an answer to your question, but maybe a suggestion for avoiding the problem.

Why are you running gcloud auth login repeatedly? 

If it is a stable machine, then the credentials for the authenticated principal will be cached into  ~/.config/gcloud/credentials.db  , or on Windows, I think C:\Users\%username%\AppData\Roaming\gcloud\credentials .

You should not NEED to always login.  

 

The auth token/session generated by the CLI login process lasts for only 1 hour. The CLI has an internal process for refreshing the token for up 8(?) or so hours, using the credentials stored in ~/.config/gcloud/credentials.db like you said, but this process is not exposed to the user.

For example: We're using gcloud as the credential helper for Docker (https://cloud.google.com/sdk/gcloud/reference/auth/configure-docker). In order to reduce the number of times docker operations fail in the middle of long running jobs, we check the gcloud access token expiration time in ~/.config/gcloud/access_tokens.db and trigger a login if it's expired or close to expiring.

If there's a better way to accomplish this, please let me know.