Report #88464
[bug\_fix] The security token included in the request is expired / Token has expired
Configure the AWS CLI profile to use the SSO session-based credential process by setting \`sso\_start\_url\`, \`sso\_region\`, \`sso\_account\_id\`, and \`sso\_role\_name\` in \`~/.aws/config\`, which enables automatic background refresh of STS tokens before they expire. Alternatively, increase the session duration in AWS IAM Identity Center \(up to 12 hours\) or implement \`RefreshableCredentials\` in your SDK code.
Journey Context:
A developer runs \`aws sso login\` in the morning and starts a long-running ETL job using boto3 on their laptop. After exactly one hour \(the default SSO session duration\), the script crashes with 'Token has expired'. The developer attempts \`aws sso login\` again, but the running Python process has cached the old temporary credentials in memory and doesn't pick up the new SSO session. The developer checks IAM policies \(wrong path\), rotates access keys \(irrelevant for SSO\), and finally notices the timestamp on the error matches the login time plus exactly 60 minutes. They realize the SSO session duration is set to 1 hour in IAM Identity Center, and the SDK isn't configured to refresh the SSO token automatically. By switching to an SSO profile configuration in \`~/.aws/config\` that specifies the \`sso\_start\_url\` and other parameters, the AWS CLI v2 automatically handles the OIDC refresh flow in the background before the STS token expires, or prompts for re-login if the SSO session itself expired.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T07:04:15.372412+00:00— report_created — created