Error: (gcloud.auth.print-identity-token) No identity token can be obtained from the current credentials

Viewed 1070

On a gcloud session, I'm trying to execute a bash script that I usually don't have any issues with but today I'm receiving the following error: Error: (gcloud.auth.print-identity-token) No identity token can be obtained from the current credentials

Steps I've followed to fix this problem:

  1. Run gcloud auth list result: Able to view and confirm my account as Active.

  2. Run gcloud config set account "my account" result: Able to confirm updated properties,

  3. Run: gcloud auth application-default login result: Authorization complete for my account through browser session and gcloud.

  4. Run again the bash script command with same error.

  5. I've logged out and logged back in to my account via web browser.

I'm currently on SDK version 309.0.0 with no issues in the past few days, until now. Any help is greatly appreciated.

2 Answers

The error appears to be from gcloud complaining that it's unable to get an ID token for your current credentials.

Can you...

gcloud auth print-identity-token

Or:

gcloud auth print-identity-token --account="my account"

This is the complaint in the error that that command is not working. BTW, once you get an ID token, you may validate it:

TOKEN=$(gcloud auth print-identity-token)
$(which chromium) https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=${TOKEN}

NOTE please double-check the URL I've given you to ensure it's a valid Google token endpoint

Application Default Credentials and the gcloud auth application-default login are unrelated to your error unless your script uses a Google Client Library that expects these credentials.

In that case, it is better to create a service account with the appropriate role and pass its key to your script using:

export GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json
./your-script.sh

There was an update being pushed by Google that caused this behavior, fix has been rolled out and I'm now able to print out my auth token.

Related