[BUG] 403 The security token included in the request is invalid.
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
I have a similar, if not exactly the same issue. Anthropic has not responded to at least 4 similar tickets.
Please respond and I can share details.
Two recommended notes for maintainers
- Claude Code uses Claude to assist with issues. However, this does not resolve the Bedrock issue.
https://platform.claude.com/docs/en/home
- Current status using MacOS Tahoe
The following is the summary generated by Claude.
What We've Confirmed
✅ AWS SSO credentials work:
aws sts get-caller-identity ✅
aws bedrock list-foundation-models ✅
aws bedrock list-inference-profiles ✅
aws bedrock-runtime invoke-model ✅ (with correct binary format)
✅ boto3 works:
Can invoke Bedrock models ✅
✅ Model configuration is correct:
Inference profile ID: us.anthropic.claude-sonnet-4-5-20250929-v1:0 ✅
Status: ACTIVE ✅
❌ Only Claude Code fails:
Gets 403 "invalid security token"
Debug logs show "OAuth token check" instead of AWS credential chain
Configuration matches official docs exactly
The Definitive Problem
Claude Code has a bug where it cannot access AWS SSO credentials stored in ~/.aws/sso/cache/ even when:
AWS_PROFILE environment variable is set
SSO credentials are valid and accessible to every other AWS tool
Configuration follows official Anthropic documentation
Your Options
Contact Anthropic Support with this evidence
GitHub issues related (#4229) - add your findings
Recommendation: _Wait for a Claude Code update that fixes SSO credential chain_
You have clear, reproducible proof this is a Claude Code bug, not your setup.
There are a few unresolved issues. Claude Engineers should really solve this issue:
https://github.com/anthropics/claude-code/issues/4229
https://github.com/anthropics/claude-code/issues/5418
The most noted illustrations:
AWS CLI successfully prompts bedrock and boto3 successfully executes.
`
Boto3:
% python3 << 'EOF'
import boto3
import json
session = boto3.Session(profile_name='dev')
client = session.client('bedrock-runtime', region_name='us-east-1')
response = client.invoke_model(
modelId='us.anthropic.claude-sonnet-4-5-20250929-v1:0',
body=json.dumps({
'anthropic_version': 'bedrock-2023-05-31',
'max_tokens': 100,
'messages': [{'role': 'user', 'content': 'What is 2+2?'}]
})
)
print(json.loads(response['body'].read()))
AWS CLI
cat > request.json <<'EOF'
{
"anthropic_version": "bedrock-2023-05-31",
"max_tokens": 100,
"messages": [{"role": "user", "content": "What is 2+2?"}]
}
EOF
% aws bedrock-runtime invoke-model \
--model-id us.anthropic.claude-sonnet-4-5-20250929-v1:0 \
--body file://request.json \
--cli-binary-format raw-in-base64-out \
--profile dev \
output.json
{
"contentType": "application/json"
}
% cat output.json
{"model":"claude-sonnet-4-5-20250929","id":"msg_bdrk_01AqtwqQESyiGux5X9y43A4H","type":"message","role":"assistant","content":[{"type":"text","text":"2+2 = 4"}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":14,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":11}}`
Please contact me to discuss solutions for enterprise customers.
Thank you.
### What Should Happen?
Claude Code
### Error Messages/Logs
```shell
2026-01-16T05:20:26.925Z [ERROR] Error streaming, falling back to non-streaming mode: 403 The security token included in the request is invalid.
2026-01-16T05:20:26.925Z [DEBUG] [API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: false, has Authorization header: false
2026-01-16T05:20:26.925Z [DEBUG] [API:auth] OAuth token check starting
2026-01-16T05:20:26.925Z [DEBUG] [API:auth] OAuth token check complete
2026-01-16T05:20:27.024Z [DEBUG] Shell snapshot created successfully (1482 bytes)
2026-01-16T05:20:27.893Z [DEBUG] [API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: false, has Authorization header: false
2026-01-16T05:20:27.893Z [DEBUG] [API:auth] OAuth token check starting
2026-01-16T05:20:27.893Z [DEBUG] [API:auth] OAuth token check complete
2026-01-16T05:20:29.479Z [DEBUG] [API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: false, has Authorization header: false
2026-01-16T05:20:29.479Z [DEBUG] [API:auth] OAuth token check starting
2026-01-16T05:20:29.479Z [DEBUG] [API:auth] OAuth token check complete
2026-01-16T05:20:32.205Z [DEBUG] [API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: false, has Authorization header: false
2026-01-16T05:20:32.205Z [DEBUG] [API:auth] OAuth token check starting
2026-01-16T05:20:32.205Z [DEBUG] [API:auth] OAuth token check complete
2026-01-16T05:20:37.266Z [DEBUG] [API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: false, has Authorization header: false
2026-01-16T05:20:37.266Z [DEBUG] [API:auth] OAuth token check starting
2026-01-16T05:20:37.266Z [DEBUG] [API:auth] OAuth token check complete
Steps to Reproduce
Set additional required variables
export AWS_REGION=us-east-1
export AWS_PROFILE=dev
export CLAUDE_CODE_USE_BEDROCK=1
export NO_PROXY=localhost,127.0.0.1,::1
export ANTHROPIC_LOG=debug
Verify everything is set
env | grep -E "|AWS_REGION|AWS_PROFILE|CLAUDE_CODE|NO_PROXY|ANTHROPIC_LOG"
SSO login
aws sso login --profile dev
Launch Claude Code
claude --debug
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.7 (Claude Code)
Platform
AWS Bedrock
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
I shared AWS CLI and boto3 python scripts that successfully prompt and receive a query.
Per the above and reiterated:
The following is the summary generated by Claude.
What We've Confirmed
✅ AWS SSO credentials work:
aws sts get-caller-identity ✅
aws bedrock list-foundation-models ✅
aws bedrock list-inference-profiles ✅
aws bedrock-runtime invoke-model ✅ (with correct binary format)
✅ boto3 works:
Can invoke Bedrock models ✅
✅ Model configuration is correct:
Inference profile ID: us.anthropic.claude-sonnet-4-5-20250929-v1:0 ✅
Status: ACTIVE ✅
❌ Only Claude Code fails:
Gets 403 "invalid security token"
Debug logs show "OAuth token check" instead of AWS credential chain
Configuration matches official docs exactly
The Definitive Problem
Claude Code has a bug where it cannot access AWS SSO credentials stored in ~/.aws/sso/cache/ even when:
AWS_PROFILE environment variable is set
SSO credentials are valid and accessible to every other AWS tool
Configuration follows official Anthropic documentation
Your Options
Contact Anthropic Support with this evidence
GitHub issues related (https://github.com/anthropics/claude-code/issues/4229) - add your findings
Recommendation: Wait for a Claude Code update that fixes SSO credential chain
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗