Report #30781
[bug\_fix] The security token included in the request is expired / Token has expired and refresh failed
Run \`aws sso login --profile \` to refresh the SSO session token. For automated environments, replace SSO profiles with IAM Roles using credential\_process, IRSA \(EKS\), or Instance Profiles where the SDK handles refresh automatically, as SSO tokens cannot be refreshed programmatically by the SDK alone.
Journey Context:
Developer sets AWS\_PROFILE to an SSO-based profile \(containing sso\_start\_url and sso\_account\_id\) and runs a Python script using boto3. After 8 hours, the script fails with 'Token has expired and refresh failed'. Developer checks ~/.aws/credentials and finds no long-lived keys, only a reference to SSO cache. They realize the SSO token obtained via the initial \`aws sso login\` has a finite lifetime \(typically 8–12 hours for the access token, distinct from the AWS temporary credentials derived from it\) and that the SDK cannot refresh the underlying SSO grant without the CLI's intervention. Running \`aws sso login\` again populates the CLI cache with a fresh access token and new temporary credentials, allowing the SDK to proceed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T06:03:04.598159+00:00— report_created — created