[BUG] Auth broken in all IDE extensions since 2.1.32 — "Invalid API key" / "Invalid bearer token" 401
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?
Works: CLI, desktop app
Broken: VS Code, Antigravity, code-server
Both "Invalid API key" and "Invalid bearer token" errors
Clean reinstall, keychain cleared, fresh login — still fails
OS: macOS (Apple Silicon/Homebrew)
Install method: Homebrew cask (claude-code)
Previously had: npm global install at 2.0.36 alongside brew at 2.1.32 — uninstalled npm, relinked brew (however this was a red heron)
Auth method: OAuth (Pro/Max subscription, not API key)
The "Fix external API key" error suggests the extension is incorrectly detecting OAuth auth as an external API key
apiKeyHelper error on startup: Error getting API key from apiKeyHelper (in settings or ~/.claude.json): apiKeyHelper did not return a valid value — despite no apiKeyHelper being configured
Manual login paste method also fails with same 401
VS Code extension version tried: current + previous downgrade, same result
~/.claude.json has no API key fields, only standard config
Keychain cleared, all auth files deleted, fresh login — CLI works immediately after, IDE still fails
That apiKeyHelper error is probably the smoking gun — the extension is looking for an API key helper that doesn't exist instead of using the OAuth token that the CLI uses successfully. Worth highlighting that prominently.
What Should Happen?
The IDE extension should authenticate using the same OAuth token/flow that the CLI successfully uses. When running claude login and authenticating via browser, the resulting credentials should be shared and work across both CLI and IDE extension contexts. The extension should not fall back to looking for an apiKeyHelper or external API key when OAuth credentials are present and valid.
Error Messages/Logs
Failed to authenticate. API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"Invalid bearer token"},"request_id":"req_....
Steps to Reproduce
- Install Claude Code via Homebrew cask (brew install claude-code)
- Run claude login in terminal — authenticates successfully
- Verify CLI works: echo "hello" | claude -p — works fine
- Open VS Code with Claude Code extension installed
- Claude Code panel shows "Invalid API key · Fix external API key"
- Click login / run /login from within the extension
- Complete OAuth flow in browser
- Returns: Failed to authenticate. API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"Invalid bearer token"}}
- Same result with manual paste login method
- Same result in Antigravity and code-server — any IDE context fails
- Cleared keychain, deleted all auth/credential files, fresh login — CLI still works, IDE still fails
- Console shows on startup: Error getting API key from apiKeyHelper (in settings or ~/.claude.json): apiKeyHelper did not return a valid value despite no apiKeyHelper being configured
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.32
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
I think this was after the release of the latest 2.1.33 VS Code extension and the Opus release its all sort of died since then.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗