`InvalidClientTokenId: The security token included in the request is invalid.`
BeginnerTroubleshootingAuthentication and Cloud API Errors
Answer
Likely causes → Deleted/rotated access keys still in env vars or ~/.aws/credentials; a session token missing (AWS_SESSION_TOKEN not set for temporary creds); using credentials in an opt-in region not enabled for the account.
Diagnose → aws configure list shows which source is in use.
Fix → Remove stale AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY, set all three values for temporary creds, or re-login via SSO.
Prevent → Prefer SSO and OIDC over long-lived keys.
More on Authentication and Cloud API Errors
`Error: No valid credential sources found` followed by `no EC2 IMDS role found ... context deadline exceeded`.Beginner`Error: Cannot assume IAM Role` — `api error AccessDenied: User: arn:aws:iam::111111111111:user/ci is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::222222222222:role/terraform`.IntermediateGitHub Actions: `Could not assume role with OIDC: Not authorized to perform sts:AssumeRoleWithWebIdentity`.IntermediateGitHub Actions log says `It looks like you might be trying to authenticate with OIDC. Did you mean to set the id-token permission?`BeginnerApplies that run longer than an hour fail with `ExpiredToken: The security token included in the request is expired`.Intermediate`failed to refresh cached credentials, refresh cached SSO token failed, unable to refresh SSO token ... InvalidGrantException`.Beginner