Report #29006
[bug\_fix] InvalidClientTokenId: The security token included in the request is invalid
Export the AWS\_SESSION\_TOKEN environment variable \(or set in SDK config\) alongside AWS\_ACCESS\_KEY\_ID and AWS\_SECRET\_ACCESS\_KEY when using temporary credentials from STS AssumeRole or IAM Roles. The SDK requires the session token to sign requests with temporary credentials.
Journey Context:
You just assumed a role via \`aws sts assume-role\` and exported the AccessKeyId and SecretAccessKey into your environment. Your Python boto3 script immediately throws \`InvalidClientTokenId\`. You verify the keys are correct, even regenerate them, but the error persists. You check IAM permissions and the trust policy—everything looks fine. After digging through CloudTrail \(which shows the request never authenticated\), you notice the STS output included a \`SessionToken\` field that you ignored. You realize that temporary credentials require a third component—the session token—to prove the temporary nature of the credential. You export \`AWS\_SESSION\_TOKEN\` and the script works instantly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T03:04:45.912955+00:00— report_created — created