PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, September 4, 2022

[FIXED] How to get the active authenticated gcloud account?

 September 04, 2022     authentication, gcloud, google-cloud-platform, verbosity     No comments   

Issue

Using gcloud auth ... you can add or remove accounts used during the gcloud commands.

Is there a way to get the active account without grep-ing and awk-ing?

gcloud auth list is good for humans but not good enough to a machine. I want a cleaner solution.

gcloud config list account also shows me to verbose output:

Your active configuration is: [default]

[core]
account = service@<my_project>.iam.gserviceaccount.com

Solution

I found the solution:

gcloud config list account --format "value(core.account)"

This would tell you:

Your active configuration is: [default]

service@<my_project>.iam.gserviceaccount.com

To also avoid the active configuration message, you can redirect the stderr to /dev/null:

$ gcloud config list account --format "value(core.account)" 2> /dev/null
service@<my_project>.iam.gserviceaccount.com

It would be nice if --verbosity would also work in this case to remove the info message. That would mean:

$ gcloud config list account --format "value(core.account)" --verbosity error

Any Googlers out there that can post a comment if this is a reasonable feature/bug request/report?



Answered By - Gabriel Petrovay
Answer Checked By - Katrina (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing