Replies: 2 comments 3 replies
-
|
AWS CLI does not have a built-in “auto-run For security reasons the CLI will not silently re-authenticate, because SSO login may require interactive browser/device authorization. When the cached SSO token expires and refresh fails, the CLI returns the error you see and expects you to re-run What you can do instead: Use the device-code flow (often easier to script around in terminals): aws sso login --profile my-profile --use-device-code Wrap your AWS CLI calls in a small script that retries once after triggering login. Example pattern: aws sts get-caller-identity --profile my-profile 1>nul 2>nul || aws sso login --profile my-profile Or, if you are using named SSO sessions (sso-session), call login for that session: aws sso login --sso-session mysession Practical recommendation: Run |
Beta Was this translation helpful? Give feedback.
-
Current behavior (example): Your SSO session is already expired. The CLI immediately fails with: The CLI will NOT:
Required manual step: If you want this behavior automatically, you must wrap it yourself, for example:
Normal browser-based login: Device-code login (example in SSH / remote terminal): CLI prints something like: You open a browser on any machine, enter the code, approve access. Important practical point:
Direct command example: Expired session output: Wrapper logic example (conceptual):
This avoids unnecessary logins and avoids masking real errors.
Example scenario:
What happens in practice:
Administrative fix example:
Result:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Whenever the AWS CLI complains that the session token has expired (
Error when retrieving token from sso: Token has expired and refresh failed), I manually runaws sso login --sso-session. This is tedious, and I couldn't find a way to automate this.Beta Was this translation helpful? Give feedback.
All reactions