Report #15482
[bug\_fix] GCP 'invalid\_grant: Token has been expired or revoked' for Service Account Key
Generate a new service account key and update your application to use it, or migrate to Workload Identity Federation to eliminate keys entirely. The root cause is that the specific service account key \(identified by the private\_key\_id in your JSON file\) has been deleted, disabled, or the service account itself has been deleted, causing the OAuth2 token endpoint to reject the signed JWT assertion with 'invalid\_grant'.
Journey Context:
A developer sets up a CI/CD pipeline using a service account key stored as a secret. The JSON key file \`service-account.json\` is uploaded to the CI secret store. The pipeline runs \`gcloud auth activate-service-account --key-file=service-account.json\` followed by \`gcloud storage cp ...\`. After several months of stable operation, the pipeline suddenly fails with \`google.auth.exceptions.RefreshError: \('invalid\_grant: Token has been expired or revoked.', \{'error': 'invalid\_grant', 'error\_description': 'Token has been expired or revoked.'\}\)\`. The developer checks the service account in the GCP Console and discovers that the specific key \(identified by the \`private\_key\_id\` in the JSON file\) no longer appears under the service account's Keys tab; it was deleted during a routine security cleanup. The developer generates a new key, updates the CI secret, and the pipeline resumes. Alternatively, they refactor to use Workload Identity Federation, binding the CI/CD workload identity directly to the service account without using keys, preventing future recurrence.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T00:16:19.006610+00:00— report_created — created