Report #75596
[bug\_fix] AWS CLI returns 'Error: The SSO session associated with this profile has expired or is otherwise invalid' when running any command
Execute 'aws sso login --profile ' to refresh the OIDC token; do not manually populate AWS\_ACCESS\_KEY\_ID/AWS\_SECRET\_ACCESS\_KEY for SSO profiles as they are derived tokens.
Journey Context:
The developer runs 'aws s3 ls' and receives the expired SSO session error. Checking '~/.aws/credentials', they find the profile section is missing or empty, leading them to believe credentials were deleted. They attempt to export legacy long-term access keys from another account, resulting in 'InvalidClientTokenId' or 'AccessDenied'. They then inspect '~/.aws/sso/cache/' and notice JSON files containing 'expiresAt' timestamps that passed hours ago. Realizing the CLI uses OIDC tokens \(not static AWS keys\) to exchange for temporary STS credentials via the 'sso\_role\_name', they understand that 'aws sso login' re-performs the browser-based OIDC flow with the Identity Provider \(IdP\), obtaining a fresh access token and refresh token. This allows the CLI to call STS AssumeRole without ever storing long-term credentials on disk, resolving the expiration.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T09:29:04.406383+00:00— report_created — created