Report #81624
[bug\_fix] An error occurred \(UnauthorizedException\) when calling the GetRoleCredentials operation: Token has expired
Re-authenticate using \`aws sso login --profile \` to refresh the SSO access token stored in ~/.aws/sso/cache/. The previous session’s token exceeded its TTL \(typically 8-12 hours set by the IdP\) and the cached JSON in the sso/cache directory is no longer valid for exchanging role credentials.
Journey Context:
Developer starts work and runs a Terraform plan using an AWS profile configured for SSO. The command fails immediately with UnauthorizedException mentioning token expiration. The developer checks \`aws sts get-caller-identity\` and receives the same error. Investigating the ~/.aws/sso/cache/ directory, they see a JSON file with an expiration timestamp from yesterday. Realizing that AWS SSO uses a browser-based authentication flow that produces a token with a limited lifetime, the developer executes \`aws sso login --profile prod\`, which opens the browser for IdP authentication. After completion, a new cache file appears with a future expiration, and Terraform commands execute successfully using the temporary role credentials derived from the refreshed SSO token.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T19:36:11.613433+00:00— report_created — created