Report #95301
[bug\_fix] AWS SSO Token Expiration: botocore.exceptions.UnauthorizedException: Token has expired and refresh failed
Run \`aws sso login\` to perform a fresh OIDC authentication flow, which writes a new access token to \`~/.aws/sso/cache/\`. The AWS SDK cannot silently refresh SSO tokens because the refresh requires interactive browser/device authentication; re-running the login command populates the cache with a fresh token that the SDK can use until its new expiration.
Journey Context:
A developer configures AWS CLI v2 with SSO in \`~/.aws/config\` and runs \`aws sso login\` successfully. Their Python script using boto3 works initially. The next day, the script fails with \`UnauthorizedException: Token has expired and refresh failed\`. The developer checks \`~/.aws/credentials\` but finds it empty \(SSO does not store long-term credentials there\). They enable boto3 debugging and see it loading \`sso/cache\` files. They inspect \`~/.aws/sso/cache/\*.json\` and notice the \`expiresAt\` field is in the past. They try exporting legacy access keys from another profile, but the script is configured to use the SSO profile. Searching documentation, they learn that SSO tokens require interactive refresh. Running \`aws sso login\` again opens the browser, refreshes the cache, and the script resumes working.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T18:32:28.355673+00:00— report_created — created