Sophie Alpert
Sophie Alpert

Reputation: 143194

Look up the email for my current Google application-default credentials (ADC)?

I set up Google Cloud application-default credentials using gcloud auth application-default login but now I can't remember which account I used to log in.

I know that gcloud auth list will print out the account I used for gcloud auth login, but there's no gcloud auth application-default list. How can I check which account is used for my ADC?

Upvotes: 3

Views: 1705

Answers (1)

Sophie Alpert
Sophie Alpert

Reputation: 143194

By default, gcloud auth application-default login includes the https://www.googleapis.com/auth/userinfo.email OAuth scope, so you can access the userinfo API using an access token from your application-default credentials.

Run this command in your terminal:

curl -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
  https://www.googleapis.com/oauth2/v1/userinfo

Example output:

{
  "id": "12345",
  "email": "[email protected]",
  "verified_email": true,
  "picture": "https://...",
  "hd": "mydomain.com"
}

Upvotes: 10

Related Questions