Report #7989
[bug\_fix] invalid\_grant: Token has been expired or revoked \(JWT 'iat' claim validation failed\)
Synchronize the system clock with NTP \(e.g., \`sudo chronyc makestep\` or \`sudo sntp -s time.google.com\`\). Ensure the machine's time is within ~5 minutes of Google servers.
Journey Context:
Developer exports GOOGLE\_APPLICATION\_CREDENTIALS pointing to a valid service account JSON. Code runs fine on a production GCE VM. Developer clones the repo to a local laptop, sets the same env var, and immediately gets 'invalid\_grant' on the first API call. They regenerate the JSON key twice, check IAM permissions \(roles/editor\), and verify the service account email is correct. They try using \`gcloud auth activate-service-account\` directly and see the same error. Finally, they run \`date\` on the laptop and notice it is 7 minutes behind the actual time. After running \`sudo chronyc makestep\`, the code works immediately. The root cause is that Google's OAuth 2.0 token endpoint validates the 'iat' \(issued at\) claim in the JWT assertion generated from the service account key; if the timestamp is too far in the past or future relative to server time, it rejects the grant.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:16:33.477998+00:00— report_created — created