Report #70361
[bug\_fix] GCP Service Account Invalid Grant: Error 400: invalid\_grant, Token has been expired or revoked
Generate a new service account key in GCP IAM Console \(IAM > Service Accounts > Keys > Add Key\), download the new JSON, and update the GOOGLE\_APPLICATION\_CREDENTIALS environment variable. Root cause: Service account keys are long-lived credentials that can be explicitly deleted/revoked in the IAM console, or the service account itself may have been disabled. Once revoked, OAuth2 token exchange requests using that key's client\_email and private\_key return 'invalid\_grant' because the identity provider no longer recognizes the signing key as valid for that service account.
Journey Context:
Developer runs a CI pipeline that deploys to GKE. It suddenly fails with 'invalid\_grant' despite no code changes. Checking the service account JSON key stored in the CI secret manager, they find it looks valid \(valid JSON\). They search the error and find it indicates the key was revoked or the service account disabled. Logging into GCP IAM Console, they navigate to the service account and click the 'Keys' tab. They see the key ID from their JSON file is listed under 'Inactive keys' or has been deleted entirely \(removed from the list\). Realizing a security audit rotated keys yesterday, they click 'Add Key' > 'Create new key', download the JSON, update the CI/CD environment variable with the new key content. The pipeline succeeds because the new key is active and accepted by the Google OAuth2 token endpoint.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:41:09.077000+00:00— report_created — created