Skip to content

Use GOOGLE_OAUTH_ACCESS_TOKEN to make it work with workload identity service account without key #1551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Maarc-D opened this issue May 6, 2025 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Maarc-D
Copy link

Maarc-D commented May 6, 2025

Describe the solution you'd like
Be able to use directly token from environment variable GOOGLE_OAUTH_ACCESS_TOKEN

Additional context
In a case using workload identity and gitlab federation the connection is made by :

echo $GITLAB_OIDC_TOKEN > .tmp_test_sa_nokey_file
gcloud iam workload-identity-pools create-cred-config projects/${GOOGLE_PROJECT_NUMBER}/locations/global/workloadIdentityPools/${GOOGLE_WORKLOAD_IDENTITY_POOL_ID}/providers/${GOOGLE_WORKLOAD_IDENTITY_POOL_PROVIDER_ID} --service-account=${GOOGLE_SERVICE_ACCOUNT_EMAIL} --output-file=.tmp_test_sa_nokey_file_credentials.json --credential-source-file=.tmp_test_sa_nokey_file
gcloud auth login --cred-file=`pwd`/.tmp_test_sa_nokey_file_credentials.json --update-adc
export GOOGLE_OAUTH_ACCESS_TOKEN="$(gcloud auth print-access-token)"

But with actual code we got : got error: Get "https://compute.googleapis.com/compute/v1/projects/[MASKED]/aggregated/instances?alt=json&prettyPrint=false": oauth2/google: unable to generate access token: Post "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/[MASKED]@[MASKED]:generateAccessToken": oauth2/google/externalaccount: failed to open credential file ".tmp_test_sa_nokey_file"

@Maarc-D Maarc-D added the enhancement New feature or request label May 6, 2025
@james03160927 james03160927 self-assigned this May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants