Report #96667
[bug\_fix] aws sso login succeeds but API calls fail with 'InvalidTokenException: The security token included in the request is expired'
Delete the cached SSO tokens in \`~/.aws/sso/cache/\` and run \`aws sso login\` again. Root cause: AWS SSO \(IAM Identity Center\) stores OIDC access tokens locally in JSON files. These tokens have a fixed lifetime \(typically 8-12 hours or defined by the permission set session duration\). When they expire, or if the permission set policies are modified, the cached token becomes invalid, and the AWS SDK cannot refresh it without a new interactive login.
Journey Context:
You start your workday and run \`aws sso login --profile production\`. The browser opens, you authenticate, and the CLI reports 'Successfully logged in'. You immediately run \`aws sts get-caller-identity --profile production\` and get an 'InvalidTokenException'. You check your system clock; it's correct. You look in \`~/.aws/sso/cache/\` and find a JSON file with an \`expiresAt\` field showing yesterday's date. You realize that despite the 'Successfully logged in' message, the CLI reused an existing expired cached token from a previous session, or the new token was written with a stale timestamp. You delete all JSON files in the cache directory, run \`aws sso login\` again, and the API call succeeds with a fresh token.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T20:50:36.091702+00:00— report_created — created