[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

Resolved 💬 26 comments Opened Nov 23, 2025 by user-png-maker Closed May 17, 2026

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)

  1. Install the Claude VS Code extension (version 2.0.5.0).
  2. Open the Claude sidebar / chat panel in VS Code.
  3. Type /login.
  4. In the login options, choose:

“Anthropic Console (pay for API users through your console account)”.

  1. 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.”

  1. 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:

  1. Create a new API key in the Anthropic Console.
  2. Use the extension’s UI to enter the API key when prompted (instead of relying on the OAuth flow).
  3. 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:

  1. 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"

  1. 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"

  1. 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

  1. 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).
  2. Install the Claude VS Code extension, version 2.0.5.0, from the VS Code Marketplace.
  3. Open the Claude view/panel (sidebar icon) and create a new Claude chat tab.
  4. In the Claude input box, type /login and press Enter.
  5. In the login options that appear, choose:

“Anthropic Console (pay for API users through your console account)”.

  1. A browser window opens. In that browser window:
  2. Sign in to your Anthropic Console account which has API-based billing enabled.
  3. Authorize Claude Code when prompted.
  4. The browser shows a success message similar to:

“Building something great. You’re set up for Claude Code. You can now close this window.”

  1. Close the browser window and return to VS Code.
  2. In the Claude panel, try to send any prompt (e.g. “hello”) in the chat tab.
  3. 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):

  1. In the Anthropic Console, create a new API key.
  2. 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.
  3. Paste the valid API key from the Anthropic Console and confirm.
  4. After submitting the key, observe that the Claude panel in VS Code turns completely black (no UI, no messages or buttons).
  5. Open a new Claude tab in the extension.
  6. 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_

View original on GitHub ↗

26 Comments

github-actions[bot] · 7 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/12105
  2. https://github.com/anthropics/claude-code/issues/9364
  3. https://github.com/anthropics/claude-code/issues/12196

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

user-png-maker · 7 months ago

This issue is related to #12105, #9364, and #12196 but is not an exact duplicate.

  • #12105: similar “Invalid API key · Please run /login” error, but on Windows.
  • #9364: similar empty/blank sidebar on macOS after login, but without the repeated “Invalid API key” message.
  • #12196: similar OAuth / authentication problems on macOS, but focused on recurring 401 “Invalid OAuth token” errors.

My case combines all of these:

  • macOS + VS Code extension 2.0.5.0
  • Anthropic Console with API-based billing only (no Claude Pro subscription)
  • After Anthropic Console OAuth login, the VS Code panel still shows “Invalid API key · Please run /login”.
  • After entering a manually created API key from the Console, the Claude panel turns completely black, and opening a new tab sends me back into the /login loop.

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.

ahnberg · 7 months ago

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.

horiacristescu · 7 months ago
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 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 :-)

ahnberg · 7 months ago

Another update of the extension; and still fails. How can they not catch this error? How can we debug it?

phazon90 · 7 months ago

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

RTGLW · 7 months ago

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 /login loop.

Nadjib6 · 7 months ago

did anyone solved it ?

GuiThereziano · 7 months ago

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!

fencyty · 7 months ago

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.

GuiThereziano · 7 months ago

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

  1. I first uninstalled the claude code extension from vscode.
  2. manually deleted all the files and folders that had remained
  3. close vscode
  4. then performed steps 1 and 2 https://code.claude.com/docs/en/quickstart#native-install-recommended.
  5. I then manually executed the claude.exe by double clicking it, went through all the authentication steps.
  6. tried a couple of prompts
  7. restarted laptop
  8. opened vscode and installed the claude code again.
  9. re-authenticated and it worked!
thejaylu · 6 months ago
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

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!

romanz-online · 6 months ago

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

lauz1n · 6 months ago
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 1. I first uninstalled the claude code extension from vscode. 2. manually deleted all the files and folders that had remained 3. close vscode 4. then performed steps 1 and 2 https://code.claude.com/docs/en/quickstart#native-install-recommended. 5. I then manually executed the claude.exe by double clicking it, went through all the authentication steps. 6. tried a couple of prompts 7. restarted laptop 8. opened vscode and installed the claude code again. 9. re-authenticated and it worked!

this worked for me aswell :) ty @GuiThereziano

sbpoem-stack · 5 months ago
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 1. I first uninstalled the claude code extension from vscode. 2. manually deleted all the files and folders that had remained 3. close vscode 4. then performed steps 1 and 2 https://code.claude.com/docs/en/quickstart#native-install-recommended. 5. I then manually executed the claude.exe by double clicking it, went through all the authentication steps. 6. tried a couple of prompts 7. restarted laptop 8. opened vscode and installed the claude code again. 9. re-authenticated and it worked!

This method solved my problem. Thank you.

eryet · 5 months ago
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 1. I first uninstalled the claude code extension from vscode. 2. manually deleted all the files and folders that had remained 3. close vscode 4. then performed steps 1 and 2 https://code.claude.com/docs/en/quickstart#native-install-recommended. 5. I then manually executed the claude.exe by double clicking it, went through all the authentication steps. 6. tried a couple of prompts 7. restarted laptop 8. opened vscode and installed the claude code again. 9. re-authenticated and it worked!

it still works for me after skipping the restart part, u can verify account linked through Account & Usage in the extension

joyahmed · 5 months ago

Am Using WSL. Faced the same issue and found this thread.

Did the followings which worked for me:

  1. Uninstalled VS Code Claude Extension (didn't close vs code even)
  2. Did native installation
  3. Authorized
  4. Installed the extension again
  5. It didn't even ask for autorization and started working

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

wUEZRs · 5 months ago

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

andreaswiren · 4 months ago

Is there any real proper fix to this? This is still a bug and we shouldnt need more tools than the extension installed.

ohmymrmac · 4 months ago

I had another ENV var CLAUDE_CODE_OAUTH_TOKEN set from some other thing i tried to do. it broke login for me

as soon as I unset CLAUDE_CODE_OAUTH_TOKEN it worked.

Try seeing if you have any lingering ENV vars that are interfering with the auth

jimmy215198 · 4 months ago

Same 401 "Invalid bearer token" here, but in a different setup — adding for visibility.

Environment:

  • App: Claude Desktop (Microsoft Store version on Windows), not VS Code extension
  • Where it fails: Code tab inside Claude Desktop (Chat tab works; Code tab returns 401)
  • Auth: OAuth via claude.ai (subscription), no API key
  • OS: Windows (Store app: Claude from Microsoft Store)

What we already tried:

  1. Clean reinstall + deleted all AppData Roaming/Local Claude data
  2. Confirmed Store app uses a sandbox path for config; created a junction so %APPDATA%\Roaming\Claude points to the Store sandbox path — Desktop and the Code subprocess now read the same config.json and oauth token cache
  3. Logged out and back in (full OAuth) multiple times
  4. Code tab still returns: Failed 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.

pranavbala-mm · 4 months ago

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.

  1. Uninstalled Claude plugin on AG
  2. Installed Claude CLI
  3. Logged into Anthropic console
  4. Installed Claude on AG
  5. Logged into console again
nekelpatrick · 4 months ago

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 select Claude.ai Subscription and complete the OAuth flow
  • The browser says I’m set up successfully (“You’re all set up for Claude Code”)
  • Back in Cursor, every prompt still fails with “Invalid API key · Fix external API key”
  • It then asks me to log in again (repeat forever)

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, ~/.claude settings), 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_KEY instead 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:

  • Warn clearly when both OAuth + API key are present
  • Show which auth method is currently being used
  • Provide an in-extension way to switch/resolve conflicts (and ideally block sending requests until it’s resolved)
joshmot · 3 months ago

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.

github-actions[bot] · 1 month ago

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

github-actions[bot] · 9 days ago

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.