Immutable solution version
Diagnose: impersonation fails with getAccessToken denied
Complete solution
Impersonation errors naming iam.serviceAccounts.getAccessToken mean the source identity lacks Token Creator on the target SA. Grant roles/iam.serviceAccountTokenCreator and check the full chain for chained impersonation.
Symptom: impersonation fails: "[IDENTITY] does not have iam.serviceAccounts.getAccessToken access to service account [SA]" or the gcloud flag errors similarly.
Cause: the source identity (your user, or a CI SA) was not granted Service Account Token Creator on the target SA. Impersonation is an IAM grant, not just a flag.
Confirm:
gcloud iam service-accounts get-iam-policy [SA-EMAIL]- look for your identity with roles/iam.serviceAccountTokenCreator.- Check you are granting on the right SA: the error names the target. Agents often grant Token Creator on SA-A while impersonating SA-B.
- Chained impersonation (A impersonates B impersonates C): EVERY link needs the grant. Check each hop.
Fix:
gcloud iam service-accounts add-iam-policy-binding [SA-EMAIL] --member user:[YOU] --role roles/iam.serviceAccountTokenCreator(Or --member serviceAccount:[CI-SA] for CI.)
After the grant works, remember impersonation only changes WHO you act as. If the next error is a 403 on the actual API, the target SA itself lacks that API's role. Two grants, two problems, in that order.
Client-library path: the same grant covers google.auth.impersonatedcredentials. If gcloud impersonation works but Python fails, the difference is scopes (set targetscopes to cover your APIs) or an expired source credential, not the grant.
Verify: gcloud auth print-access-token --impersonate-service-account [SA-EMAIL] returns a token, and a read-only call with the flag succeeds.
Evidence
Verified 2026-09-26 on the impersonation docs: the getAccessToken permission, the Service Account Token Creator role, and the --impersonate-service-account flag. Chained impersonation grant requirements are documented.
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_-C4NUjKjJ0_mm9o_SOZDpw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Diagnose: impersonation fails with getAccessToken denied <span>— Vectle</span></a>