[BUG] VS Code extension 2.0.5.0: Invalid API key · Please run /login and black screen even after successful Anthropic Console OAuth and manual API key setup
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’m unable to use the Claude VS Code extension (version 2.0.5.0) at all.
No matter what I do, the chat panel either shows:
Invalid API key · Please run /login
or goes completely black after entering an API key.
This happens both:
• after a successful Anthropic Console OAuth login (browser says I’m set up), and
• even when I manually configure an API key from the Anthropic Console.
It looks like the extension never actually stores or recognizes the credentials after login or manual key entry.
⸻
Environment
• Editor: Visual Studio Code
• VS Code extension: Claude for VS Code 2.0.5.0
• OS: macOS (Apple Silicon)
• Account / billing type: Anthropic Console with API-based billing, not Claude Pro/Max
• Where it fails: Inside the Claude VS Code extension chat panel
⸻
Steps to Reproduce (OAuth path)
- Install the Claude VS Code extension (version 2.0.5.0).
- Open the Claude sidebar / chat panel in VS Code.
- Type /login.
- In the login options, choose:
“Anthropic Console (pay for API users through your console account)”.
- A browser window opens:
• I log into my Anthropic Console account (the one with API billing set up).
• I authorize the VS Code integration.
• The browser shows:
“Building something great. You’re set up for Claude Code. You can now close this window.”
- Go back to VS Code.
Expected:
• Claude in VS Code should be authenticated and accept prompts.
Actual:
• The Claude panel still shows:
Invalid API key · Please run /login
• Opening a new Claude tab and retrying leads to the same behavior.
• In one flow I also got a device/identification code, entered it, clicked Continue, and then the window just stayed black, without improving the situation in VS Code.
⸻
Steps to Reproduce (manual API key path)
I also tried using a manually created API key from the Anthropic Console:
- Create a new API key in the Anthropic Console.
- Use the extension’s UI to enter the API key when prompted (instead of relying on the OAuth flow).
- Confirm / continue.
Expected:
• After entering a valid API key, the Claude panel should become usable and accept prompts.
Actual:
• After entering the API key, the Claude panel turns completely black (no UI, no messages, nothing).
• If I open a new Claude tab:
• I’m again asked to log in / configure credentials.
• Going through the flow again does not fix the problem.
• Net result: The extension is stuck in a loop of “login / invalid API key” and black screens, even with a fresh, valid API key.
⸻
Full Reset Attempts
I have already tried a complete clean reset:
- Removed all Claude-related config directories:
rm -rf ~/.claude
rm -rf ~/.config/claude-code
rm -rf ~/.local/share/claude
rm -rf "$HOME/Library/Application Support/claude"
rm -rf "$HOME/Library/Application Support/anthropic"
- Completely wiped VS Code, including all extensions and settings:
rm -rf "/Applications/Visual Studio Code.app"
rm -rf "$HOME/.vscode"
rm -rf "$HOME/Library/Application Support/Code"
rm -rf "$HOME/Library/Application Support/Code - Insiders"
rm -rf "$HOME/Library/Caches/com.microsoft.VSCode"
rm -rf "$HOME/Library/Caches/com.microsoft.VSCode.ShipIt"
rm -rf "$HOME/Library/Preferences/com.microsoft.VSCode.plist"
rm -rf "$HOME/Library/Saved Application State/com.microsoft.VSCode.savedState"
- Rebooted, then:
• Reinstalled the latest VS Code
• Reinstalled the Claude VS Code extension 2.0.5.0
• Repeated both login methods:
• Anthropic Console OAuth
• Manual API key entry
The behavior is still the same:
• OAuth path → Invalid API key · Please run /login
• Manual API key path → Claude panel goes black, and a new tab again asks for login / key without ever succeeding.
⸻
Additional Info
• My Anthropic Console account is active, and API-based billing is enabled.
• I am not using a consumer Claude Pro subscription; everything is via the API / console billing.
• From the user perspective, it feels like:
• The OAuth flow in the browser is successful,
• A manually entered API key is also accepted by the UI,
• But the VS Code extension never transitions to an authenticated state and continues to act as if no valid credentials exist.
If helpful, I can provide:
• Exact VS Code version (Help → About)
• Exact macOS version
• Any logs / debug output that can be captured from the extension (if there is a recommended way to enable verbose logging).
⸻
Thanks a lot for looking into this – right now, the VS Code extension is effectively unusable for Anthropic Console API users in my setup, even after a full reset and manual API key configuration.
What Should Happen?
After completing the login flow (either via Anthropic Console OAuth or by entering a valid API key), the VS Code extension should store the credentials and switch into an authenticated state. The Claude panel should remain usable (no black screen), accept prompts, and respond to them without repeatedly asking to run /login or re-enter an API key. This authenticated state should persist across new Claude tabs, VS Code restarts, and normal use of the editor, as long as the credentials remain valid.
Error Messages/Logs
Steps to Reproduce
- Install Visual Studio Code on macOS and start it with a completely empty workspace (no special files or project required; the issue happens even with no folder open).
- Install the Claude VS Code extension, version 2.0.5.0, from the VS Code Marketplace.
- Open the Claude view/panel (sidebar icon) and create a new Claude chat tab.
- In the Claude input box, type /login and press Enter.
- In the login options that appear, choose:
“Anthropic Console (pay for API users through your console account)”.
- A browser window opens. In that browser window:
- Sign in to your Anthropic Console account which has API-based billing enabled.
- Authorize Claude Code when prompted.
- The browser shows a success message similar to:
“Building something great. You’re set up for Claude Code. You can now close this window.”
- Close the browser window and return to VS Code.
- In the Claude panel, try to send any prompt (e.g. “hello”) in the chat tab.
- Observe that the bottom of the Claude panel shows the error:
Invalid API key · Please run /login
and the extension continues to behave as if you are not authenticated.
Alternative reproduction path (manual API key, also broken):
- In the Anthropic Console, create a new API key.
- In the Claude VS Code extension, follow the login / setup flow that allows you to manually enter an API key instead of using the OAuth login.
- Paste the valid API key from the Anthropic Console and confirm.
- After submitting the key, observe that the Claude panel in VS Code turns completely black (no UI, no messages or buttons).
- Open a new Claude tab in the extension.
- Observe that the extension again behaves as if you were not logged in (asks to run /login or configure credentials) and never reaches a stable authenticated state, despite the valid key and the apparently successful setup.
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
v.2.0.5.0
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
26 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
This issue is related to #12105, #9364, and #12196 but is not an exact duplicate.
My case combines all of these:
Because of this combination (API-billing-only account + macOS + “Invalid API key” + black panel after manual key), this seems to be a distinct variant of the auth bug and should stay open.
I have the exact same error Claude Code extension version 2.0.56 for VS Code on Windows as well as MacOS. I type /login then I chose "Anthropic Console" and go through the Oauth flow and nothing happens, if I click the manual link and get the code and paste it back in and continue, the Claude Code window just stays empty and nothing happens no matter how long I wait.
Claude Code on the same computer in terminal works just fine with the /login flow.
I have the same error, I do the Anthropic Console login path, copy paste the code back into the extension, and it displays a blank screen as response. When I reopen the extension tab it is not logged in.
On top of this failed login method the Extension does not have proper /status and does not signal if it is logged on Cursor Pro or on Anthropic Console API path, this made me waste 30% of my weekly Pro quota (personal account) instead of using work quota on API.
So the interface login fails, while signaling the logged in state is missing. Confusing and frustrating, just use Claude Code to implement login testing and login status :-)
Another update of the extension; and still fails. How can they not catch this error? How can we debug it?
Workaround: I was able to login after first logging in via CLI (claude /login), which required logging in twice for some reason. After that I restarted VS Code and then the Claude extension seemed to sync up and start communicating as expected
I'm having the _exact_ same issue on a remote Debian (12.7) host. The host can authenticate to AWS via OAuth without issue, but I can not get the Claude Code extension to accept authentication. Stuck in the
Invalid API key · Please run /loginloop.did anyone solved it ?
I thought it was only me!! The error/bug could not be described better! I'm experiencing the exact same! Also, tried most of the troubleshooting listed, and unfortunately no lucky!
I’m experiencing the same issue. I spent quite a bit of time repeatedly troubleshooting it, but it runs normally in the terminal. Hope this bug can be fixed soon.
Had the same exact problem. I installed the CLI (native), followed the initial configuration step which includes logging in. After that, returned to my VSCode and everything is working.
From this link: https://code.claude.com/docs/en/quickstart#native-install-recommended
Can confirm this workaround worked for me on Windows as well. The extension finally recognized my authentication after the CLI authentication and is now working. Thanks!
as @GuiThereziano suggested, I installed claude on my machine outside of vscode, logged in and after restarting vscode and reinstalling the claude extension, it started working correctly. not a fix but a helpful workaround
this worked for me aswell :) ty @GuiThereziano
This method solved my problem. Thank you.
it still works for me after skipping the restart part, u can verify account linked through Account & Usage in the extension
Am Using WSL. Faced the same issue and found this thread.
Did the followings which worked for me:
Key point: authenticate the native Claude CLI first, then install the VS Code extension.
If the extension is installed before native auth, it doesn't work
Had the same problem. I did not clear any old files or uninstall anything, just:
https://code.claude.com/docs/en/quickstart#native-install-recommended
Ran 1) and 2) from here. The CLI worked well. Then opened VsCode and was no longer in a loop
Is there any real proper fix to this? This is still a bug and we shouldnt need more tools than the extension installed.
I had another ENV var
CLAUDE_CODE_OAUTH_TOKENset from some other thing i tried to do. it broke login for meas soon as I
unset CLAUDE_CODE_OAUTH_TOKENit worked.Try seeing if you have any lingering ENV vars that are interfering with the auth
Same 401 "Invalid bearer token" here, but in a different setup — adding for visibility.
Environment:
What we already tried:
%APPDATA%\Roaming\Claudepoints to the Store sandbox path — Desktop and the Code subprocess now read the sameconfig.jsonand oauth token cacheFailed to authenticate. API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"Invalid bearer token"},"request_id":"req_011CYeWnzDzpaS2SyeComXTq"}So the token is present and the path is consistent; the API still rejects the bearer token. Request ID for this occurrence:
req_011CYeWnzDzpaS2SyeComXTq.Hoping this helps narrow down backend/Code-mode auth handling. Thanks.
The same solution proposed by @GuiThereziano worked for me on Antigravity which is again a fork of VS Code, I didn't clear any files though.
Same issue in Cursor on macOS (and it caused unintended spend)
I’m seeing the same loop in Cursor (macOS) with the Claude Code extension:
I’ve already done the “it must be my setup” checklist (full cleanup + reinstall), including removing all known API-key sources (Cursor
claudeCode.environmentVariables, shell env,~/.claudesettings), and fully quitting/restarting Cursor. The extension bug still reproduces. So this doesn’t look like a local config mistake.Why this matters: before we caught it, the extension seemed to silently fall back to an older
ANTHROPIC_API_KEYinstead of using Teams OAuth, which drove unintended API usage and extra charges. Even once the key was removed, the extension still fails with the “Invalid API key” loop, so it’s both (1) easy to accidentally bill the wrong thing and (2) hard to recover back to OAuth.Request: please make the extension surface auth state like the CLI does:
Had the random thought that Apple's Advanced Protection might be the culprit. So I disabled it I was able to log in without issue. Don't know that it will be a solution for everyone but it was for me after literally trying every other solution I read of.
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
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.