Report #3605
[bug\_fix] ExpiredTokenException: The provided token has expired
Run \`aws sso login\` to refresh the SSO session, or configure the profile with \`sso\_session\` and \`sso\_role\_name\` so the SDK uses the AWS CLI's credential cache. For role chaining, ensure the parent profile uses \`sso\_session\` or has valid static credentials; do not chain more than one \`assume\_role\` without a working source\_profile.
Journey Context:
Developer runs a long-running ETL script using boto3 with credentials from \`aws configure sso\`. After 8 hours, it crashes with ExpiredTokenException. They check \`aws configure list\` and see the credentials point to the SSO cache. They restart the script but it fails immediately. They realize the SSO session itself \(the refresh token\) expired after 12 hours, distinct from the temporary AWS credentials. They run \`aws sso login\`, authenticate in the browser, and the script works. They later refactor the code to use a specific profile with \`sso\_session\` defined in \`~/.aws/config\` and add logic to catch the exception and trigger \`aws sso login\` via subprocess if a token expiry is detected.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T17:38:17.937397+00:00— report_created — created