BerriAI/litellm · error · AwsAuthError
AWS STS rejected the web identity token
Error message
AWS STS rejected the web identity token: {e}.{detail} What it means
STS call failure during assume_role_with_web_identity: AWS STS refused the exchanged web identity token (expired, invalid, or role trust misconfigured), surfacing botocore's error detail. The token or role trust policy is at fault, not the client code.
Solutions
- Verify the web identity token is valid and not expired.
- Check the IAM role trust policy allows the token's audience and issuer.
- Confirm the role ARN and OIDC provider configuration match the token.
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at litellm/llms/bedrock/base_aws_llm.py:918 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/5c792c1bbc04a445.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/bedrock/base_aws_llm.py:918
}
assume_role_params: Final = {
"RoleArn": aws_role_name,
"RoleSessionName": aws_session_name,
"WebIdentityToken": oidc_token,
"DurationSeconds": 3600,
"Policy": json.dumps(bedrock_session_policy, separators=(",", ":")),
}
# Add ExternalId parameter if provided
if aws_external_id is not None:
assume_role_params["ExternalId"] = aws_external_id
try:
sts_response: Final = sts_client.assume_role_with_web_identity(**assume_role_params)
except sts_client.exceptions.InvalidIdentityTokenException as e:
audience = self._unverified_web_identity_audience(oidc_token) if isinstance(oidc_token, str) else None
detail: Final = f" Token {audience}" if audience else ""
raise AwsAuthError(
status_code=401,
message=f"AWS STS rejected the web identity token: {e}.{detail}",
) from e
iam_creds_dict: Final = {
"aws_access_key_id": sts_response["Credentials"]["AccessKeyId"],
"aws_secret_access_key": sts_response["Credentials"]["SecretAccessKey"],
"aws_session_token": sts_response["Credentials"]["SessionToken"],
"region_name": aws_region_name,
}
if sts_response["PackedPolicySize"] > BEDROCK_MAX_POLICY_SIZE:
verbose_logger.warning(
"The policy size is greater than 75%% of the allowed size, PackedPolicySize: %s",
sts_response["PackedPolicySize"],
)
with tracer.trace("boto3.Session(**iam_creds_dict)"):View on GitHub (pinned to 77b7c6c40c)