Report #78552
[bug\_fix] GCP invalid\_grant: Token has been expired or revoked
Re-authenticate to obtain a new refresh token. For user credentials \(ADC\), run \`gcloud auth login\` or \`gcloud auth application-default login\` again. For service accounts, if using a JSON key file, ensure the key has not been deleted or rotated; if deleted, generate a new key in IAM -> Service Accounts -> Keys. Prefer using Workload Identity Federation to eliminate long-lived keys. If the service account was disabled and re-enabled, existing keys remain valid, but if the key was explicitly deleted or the service account was deleted and recreated, the key becomes invalid.
Journey Context:
Developer has a production cron job running on a Compute Engine VM that uses a service account JSON key file \(downloaded years ago\) to authenticate to BigQuery. Suddenly, all jobs start failing with 'invalid\_grant: Token has been expired or revoked'. Developer checks the service account in the GCP Console IAM section - the service account exists and has BigQuery Admin role. They check the JSON key file on the VM - it exists and looks valid \(has client\_email, private\_key\). They try running the script manually as root - same error. They search the error and find Google documentation stating 'invalid\_grant' usually means the refresh token is invalid. But they're using a service account, not a user refresh token. They check the service account's 'Keys' section in the console and realize the key ID in their JSON file does not appear in the list of active keys. They ask the security team and discover that a security audit last week deleted all service account keys older than 90 days as a policy enforcement. The key was deleted, so the private key in the JSON file is now useless \(the server-side public key was deleted\). The fix is to create a new key for the service account, download it, and replace the file on the VM. Alternatively, if this was a user credential scenario \(e.g., running \`gcloud auth application-default login\` on a laptop\), the fix would be to run the login command again because the refresh token expired after 7 days of inactivity or was revoked by the user in myaccount.google.com.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T14:26:55.719378+00:00— report_created — created