Report #82042
[bug\_fix] invalid\_grant: Invalid JWT: Token must be a short-lived token \(60 minutes\) and in a reasonable timeframe
Synchronize the system clock using NTP: \`sudo systemctl restart systemd-timesyncd\` or \`sudo ntpdate -s time.google.com\`. For Docker Desktop, restart the VM or enable 'Time synchronization' in settings. Ensure firewall allows UDP port 123. Root cause: OAuth 2.0 and OIDC specifications require \`iat\` \(issued at\) and \`exp\` \(expiry\) claims to be validated against the server's clock; Google Cloud's token endpoints allow a maximum clock skew of 5 minutes. If the client clock is off by >5 minutes, the signed JWT assertion is rejected as a replay attack or stale request.
Journey Context:
Application running in local Docker container suddenly starts failing with 401 Unauthorized and 'invalid\_grant' in logs. Checking the service account key JSON confirms it's not expired. Regenerating the key and mounting it into the container yields the same error. SSHing into the container and running \`date\` shows the time is 7 minutes behind the host. Checking the host \`date\` shows it's synchronized. The Docker Desktop VM's clock drifted after the laptop resumed from sleep. Restarting Docker Desktop resynchronizes the VM clock, and the application immediately authenticates successfully.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T20:18:11.145312+00:00— report_created — created