Gcloud auth login. Here are the steps I took.

Gcloud auth login If you look at the second option here under the How the Application Default Credentials work, you can find info on how to use it to manage the credentials for you ( gcloud auth login and gcloud auth application-default login ) Using gcloud auth you can add or remove accounts used during the gcloud commands. Also the code might change in the future. To activate your service account, run gcloud auth login with the --cred-file flag: gcloud auth login --cred-file=CONFIGURATION_OR_KEY_FILE. Another option that might make things even easier and takes care of these things automatically is using the gcloud cli tool. Replace CONFIGURATION_OR_KEY_FILE with the path to one of the following: A credential configuration file for workload identity federation; A service account key file Run gcloud auth activate-service-account --key-file <path to key file>. Share When I run gcloud auth list only the new corporate email <new_corporate_email>@domain. gcloud auth login; gcloud auth login --no-launch-browser; gcloud auth application-default login; gcloud config set account <new_corporate_email>@domain. gcloud auth application-default login And then in the script just: storage_client = storage. email An easy solution that works for me is running the gcloud CLI with the environment variable DISPLAY='X': DISPLAY='X' gcloud auth application-default login You can also set an alias: alias gauth='DISPLAY="X" gcloud auth application-default login' Troubleshooting. If your application is running on one of the Google compute services, your app should be using the metadata service or an explicitly specified service account. gcloud config list account also shows me to verbose output: gcloud auth activate-service-account --key-file=MY_KEY_FILE. com is displayed. gcloud auth application-default login -> Login to any code running on the computer (language SDK's within an application) There is also a give-away in the OAuth authentication screen in the browser windows that open up: gcloud auth login is a developer command. json You should be now set, but if you want to use it as Application Default Credentials (ADC), that is in the context of other libraries and tools, you need to set the following environment variable to point to the key file: So, gcloud auth login -> Login to gcloud SDK. So, gcloud auth login -> Login to gcloud SDK. Do not use that in production environments. json You should be now set, but if you want to use it as Application Default Credentials (ADC), that is in the context of other libraries and tools, you need to set the following environment variable to point to the key file:. Note that Google Compute Engine VMs come with a slightly-different service account; the difference is described here . Client() And it will get the credentials from the environment. I want a cleaner solution. Alternatively, you can follow this doc to go through the OAuth consent screen and generate a client secret. Here are the steps I took. 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. com; git config --global user. However, this might now work on all systems. nfbyg zlfc khsusl tvumj sywxnaf zifelqx kvxy rrcoj ogojp heugo