https://github.com/fluential/gcp-oauth-token-info
Retrieve auth token information from Google OAuth2 endpoint
https://github.com/fluential/gcp-oauth-token-info
Last synced: over 1 year ago
JSON representation
Retrieve auth token information from Google OAuth2 endpoint
- Host: GitHub
- URL: https://github.com/fluential/gcp-oauth-token-info
- Owner: fluential
- License: mit
- Created: 2024-12-04T11:38:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-04T12:23:38.000Z (over 1 year ago)
- Last Synced: 2025-03-26T19:11:25.554Z (over 1 year ago)
- Language: Python
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```shell
> export CLOUDSDK_AUTH_ACCESS_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:
```shell
export CLOUDSDK_AUTH_ACCESS_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"
}
```