Skip to content

fluential/gcp-oauth-token-info

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

gcp-oauth-token-info

Retrieve auth token information from Google OAuth2 endpoint

When working with remote GCP resources often it's good practice to relay on the CLOUDSDK_AUTH_ACCESS_TOKEN, this token can be easily obtained by doing running gcloud auth print-access-token and reused in a way like:

> export CLOUDSDK_AUTH_ACCESS_TOKEN=<token>
> gcloud compute instances list

But it's not easy to identify user identity of such tokens which is important when you work with different Service Account, environments etc. This small snippet will retrieve token info from Google API endpoint:

export CLOUDSDK_AUTH_ACCESS_TOKEN=<token>
./gcp-oauth-token-info.py
2024-12-04 05:44:50 - INFO - Token Information:
2024-12-04 05:44:50 - INFO - {
  "azp": "721552944539.apps.googleusercontent.com",
  "aud": "721552944539.apps.googleusercontent.com",
  "sub": "777455885472527483726",
  "scope": "https://www.googleapis.com/auth/accounts.reauth https://www.googleapis.com/auth/appengine.admin https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/compute https://www.googleapis.com/auth/sqlservice.login https://www.googleapis.com/auth/userinfo.email openid",
  "exp": "1733315061",
  "expires_in": "2370",
  "email": "foo@bar",
  "email_verified": "true",
  "access_type": "offline"
}

About

Retrieve auth token information from Google OAuth2 endpoint

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages