[BUG] Missing API key · Run /login - Invalid API key · Please run /login
Environment
- Platform (select one):
- [ ] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [X] Other: Claude Code CLI
- Claude CLI version: 1.0.69
- Operating System:
- Terminal: Termius
Bug Description
Even after logging in with Calude Max account we see "Missing API key · Run /login". When we try to send a prompt we get; Invalid API key · Please run /login
Steps to Reproduce
- Login
- Missing API key · Run /login appears
Expected Behavior
Not using API
Actual Behavior
As if it is trying yo use API?
Additional Context
Is this a part of coming weekly, monthly usage limits that we HAVE TO provide API keys?
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/5192
- https://github.com/anthropics/claude-code/issues/5166
- https://github.com/anthropics/claude-code/issues/5222
If your issue is a duplicate, please close it and 👍 the existing issue instead.
This issue will be automatically closed as a duplicate in 3 days if there are no additional comments. To prevent auto-closure, please 👎 this comment.
🤖 Generated with Claude Code
I see lots of duplicate issues, but none shows a clear solution...
Check this https://github.com/anthropics/claude-code/issues/5118
Downgrading to 1.0.67 did the trick for me. Do not forget to /login and close the Claude and reopen.
Downgrading to 1.0.67 did the trick for me. Do not forget to /login and close the Claude and reopen.
Aye can confirm that worked out really well, appreciate it @timyal!
Still usign 1.0.67. Even after 1.0.84 update...
I tried lots of things, unistalled, removed folder, re installed global, local, re login, logout, re login, migrate etc... None works....
Same issue here, with 1.0.88!
Still same after 1.0.92 update!!! Still using 1.0.67.
I did everything the support team suggested, but no one is able to tell "why" 1.0.67 works, while others can not?!
Same problem here. Using SSH and claude code on multiple machines. Mac.
Got this in v2.0.26 Today, 24.10.2025 - how is this bug not solved yet?
[BUG] AWS Bedrock Authentication Fails with "Missing API key" in v2.0.26
Environment
- Platform: AWS Bedrock
- Claude CLI version: v2.0.26 (also affects v1.0.68 through current)
- Operating System: Windows 11 (also reported on macOS)
- Terminal: Windows Terminal / PowerShell
- Authentication Method:
AWS_BEARER_TOKEN_BEDROCK
Bug Description
AWS Bedrock authentication via the AWS_BEARER_TOKEN_BEDROCK environment variable fails with the error:
Missing API key · Run /login
Even after setting the environment variable correctly, Claude Code throws:
Error: Could not resolve authentication method. Expected either apiKey or authToken to be set.
Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted
Steps to Reproduce
-
Set AWS Bedrock authentication:
$env:AWS_BEARER_TOKEN_BEDROCK="your-bedrock-token-here" -
Run Claude Code:
claude -
Observe error: "Missing API key · Run /login"
-
Attempt to use Claude Code → Error persists even after running
/login
Expected Behavior
When AWS_BEARER_TOKEN_BEDROCK is set, Claude Code should:
- Recognize the Bedrock bearer token as a valid authentication method
- Successfully authenticate with AWS Bedrock API
- Start the session without "Missing API key" errors
Actual Behavior
- Claude Code does not recognize
AWS_BEARER_TOKEN_BEDROCKas valid authentication validateHeaders()function throws authentication error- Users cannot use Bedrock authentication in affected versions
Root Cause Analysis
The validateHeaders() function (at cli.js:357:930) only checks for apiKey and authToken:
if (!headers.apiKey && !headers.authToken) {
throw new Error("Could not resolve authentication method...");
}
Missing: Check for process.env.AWS_BEARER_TOKEN_BEDROCK
The Bedrock token support was added in v1.0.51 (CHANGELOG.md:423), but the validation logic was never updated to recognize it.
Error Stack Trace
Error: Could not resolve authentication method. Expected either apiKey or authToken to be set.
at validateHeaders (file:///C:/dev/npm-home/node_modules/@anthropic-ai/claude-code/cli.js:357:930)
at buildHeaders (file:///C:/dev/npm-home/node_modules/@anthropic-ai/claude-code/cli.js:357:8412)
at buildRequest (file:///C:/dev/npm-home/node_modules/@anthropic-ai/claude-code/cli.js:357:7470)
at makeRequest (file:///C:/dev/npm-home/node_modules/@anthropic-ai/claude-code/cli.js:357:3309)
Proposed Fix
Update validateHeaders() to check for Bedrock authentication:
function validateHeaders(config) {
const hasApiKey = !!config.apiKey;
const hasAuthToken = !!config.authToken;
const hasBedrockToken = !!process.env.AWS_BEARER_TOKEN_BEDROCK;
const hasVertexAuth = !!process.env.GOOGLE_APPLICATION_CREDENTIALS || !!process.env.CLOUD_ML_REGION;
// Check if ANY valid authentication method is present
if (!hasApiKey && !hasAuthToken && !hasBedrockToken && !hasVertexAuth) {
throw new Error(
"Could not resolve authentication method. Expected either apiKey, authToken, " +
"AWS_BEARER_TOKEN_BEDROCK (for Bedrock), or Vertex authentication to be set."
);
}
}
Workaround
Users experiencing this issue can:
Option 1: Downgrade to v1.0.67 (confirmed working)
npm uninstall -g @anthropic-ai/claude-code
npm install -g @anthropic-ai/[email protected]
Option 2: Use OAuth Authentication
claude
/login
# Follow browser authentication
Additional Context
Related Issues
- #5235 (original report)
- #5222 (authentication errors)
- #5192 (OAuth persistence)
Version History
- v1.0.51:
AWS_BEARER_TOKEN_BEDROCKsupport added - v1.0.67: Last working version (validation bypass?)
- v1.0.68+: Regression introduced (stricter validation)
- v1.0.124: Fixed env var truthy evaluation, but not validation logic
- v2.0.26: Bug still present
Impact
- Severity: High (complete authentication failure)
- Affected Users: All Windows/Bedrock users on v1.0.68+
- Workaround: Downgrade required
Similar Certificate Error
Some users also encounter TLS errors:
Error: unable to get local issuer certificate
This is a separate corporate proxy/certificate issue and should be addressed independently.
Testing Checklist
After implementing the fix, verify:
- [ ]
AWS_BEARER_TOKEN_BEDROCKauthentication works - [ ] Standard
ANTHROPIC_API_KEYauthentication still works - [ ] OAuth authentication still works
- [ ] Vertex authentication still works
- [ ] Error message lists all valid authentication methods
- [ ] No false positives (error when auth IS present)
Files to Modify
Primary:
- Authentication validation logic (likely in
src/client.tsor similar, compiled tocli.js:357)
Functions to update:
validateHeaders()- Add Bedrock/Vertex checks- Error messages - Update to list all auth methods
Testing:
- Add integration tests for all auth methods
- Test on Windows and macOS
- Test with and without corporate proxies
Priority: 🔴 High - Blocking Bedrock users from using Claude Code
Difficulty: Easy - Single function fix
Breaking Change: No - Only adds missing validation check
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
still happening
This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.
This issue was closed incorrectly despite recent human comments. This behavior of the bot is reported at https://github.com/anthropics/claude-code/issues/16497. Please upvote that issue, so maybe it gets noticed.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.