Gcloud auth login. Here are the steps I took.
Gcloud auth login 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 auth application-default login And then in the script just: storage_client = storage. 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. 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: So, gcloud auth login -> Login to gcloud SDK. 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. gcloud config list account also shows me to verbose output: gcloud auth activate-service-account --key-file=MY_KEY_FILE. Note that Google Compute Engine VMs come with a slightly-different service account; the difference is described here . 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. I want a cleaner solution. Also the code might change in the future. Share When I run gcloud auth list only the new corporate email <new_corporate_email>@domain. 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. 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. 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>. Alternatively, you can follow this doc to go through the OAuth consent screen and generate a client secret. So, gcloud auth login -> Login to gcloud SDK. 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:. com is displayed. gcloud auth login; gcloud auth login --no-launch-browser; gcloud auth application-default login; gcloud config set account <new_corporate_email>@domain. However, this might now work on all systems. com; git config --global user. Client() And it will get the credentials from the environment. Here are the steps I took. gtr jyqbuzf tnfi pmx bfzzqau ubdn lqlj ooykq pckjvo ssqd