Report #6260
[bug\_fix] Error when retrieving token from sso: Token has expired and refresh failed, or invalid\_grant
Execute 'aws sso login --profile ' to initiate a fresh browser-based SSO session and obtain a new refresh token. Root cause: AWS SSO \(IAM Identity Center\) tokens stored in ~/.aws/sso/cache/ have a finite lifetime \(typically 8-24 hours based on IAM Identity Center configuration\) and cannot be refreshed automatically without user interaction via browser login.
Journey Context:
Developer runs AWS CLI commands using an SSO-registered profile and receives an error stating 'Token has expired' or 'invalid\_grant' from the SSO token endpoint. They check ~/.aws/credentials and find it empty or containing only old values. They check ~/.aws/config and see the profile uses 'sso\_start\_url' and 'sso\_role\_name'. The developer initially tries 'aws configure sso' again but that fails with the same error. They discover that SSO tokens are cached separately in ~/.aws/sso/cache/ as JSON files containing accessToken and expiresAt. Once these expire, the CLI cannot get new ones without the user proving identity via browser. The fix is to run 'aws sso login' which pops a browser, authorizes the CLI, and repopulates the cache with fresh tokens valid for the session duration configured in IAM Identity Center.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T23:40:31.921041+00:00— report_created — created