claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

API Error: 401 {"type":"error","error":{"type":"authenticati...

Open jackrobertscott opened this issue 1 year ago • 59 comments

Bug Description API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"Invalid OAuth token. The provided token was not found or is malformed."}}

Environment Info

  • Platform: darwin
  • Terminal: vscode
  • Version: 1.0.44
  • Feedback ID: b5e5486b-26ac-409a-b1c6-b839f8ac9f21

Errors

[{"error":"Error: Command failed: security find-generic-password -a $USER -w -s \"Claude Code\"\nsecurity: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.\n\n    at genericNodeError (node:internal/errors:983:15)\n    at wrappedFn (node:internal/errors:537:14)\n    at checkExecSyncError (node:child_process:892:11)\n    at execSync (node:child_process:964:15)\n    at wD (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:702:3921)\n    at file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:623:9350\n    at Q (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:526:13327)\n    at uC (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:623:8496)\n    at hC (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:623:7361)\n    at wB (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:623:11970)","timestamp":"2025-07-10T00:40:04.277Z"},{"error":"Error: Command failed: security delete-generic-password -a $USER -s \"Claude Code\"\nsecurity: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.\n\n    at genericNodeError (node:internal/errors:983:15)\n    at wrappedFn (node:internal/errors:537:14)\n    at checkExecSyncError (node:child_process:892:11)\n    at execSync (node:child_process:964:15)\n    at wD (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:702:3921)\n    at TpA (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:623:10462)\n    at OpA (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:623:10336)\n    at k9A (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:2125:2567)\n    at e01.startOAuthFlow (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:2125:3733)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2025-07-10T00:40:14.822Z"},{"error":"Error: Command failed: security find-generic-password -a $USER -w -s \"Claude Code\"\nsecurity: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.\n\n    at genericNodeError (node:internal/errors:983:15)\n    at wrappedFn (node:internal/errors:537:14)\n    at checkExecSyncError (node:child_process:892:11)\n    at execSync (node:child_process:964:15)\n    at wD (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:702:3921)\n    at file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:623:9350\n    at Q (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:526:13327)\n    at uC (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:623:8496)\n    at hC (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:623:7361)\n    at wB (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:623:11970)","timestamp":"2025-07-10T00:40:14.890Z"},{"error":"Error: 401 {\"type\":\"error\",\"error\":{\"type\":\"authentication_error\",\"message\":\"Invalid OAuth token. The provided token was not found or is malformed.\"}}\n    at D6.generate (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1304:12612)\n    at gq.makeStatusError (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1321:2100)\n    at gq.makeRequest (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1321:5311)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2025-07-10T00:40:29.556Z"},{"error":"SyntaxError: Unexpected token 'A', \"API Error:\"... is not valid JSON\n    at JSON.parse (<anonymous>)\n    at file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:618:9971\n    at Q (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:526:13327)\n    at Lw2 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1337:10306)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2025-07-10T00:40:29.567Z"},{"error":"Error: 401 {\"type\":\"error\",\"error\":{\"type\":\"authentication_error\",\"message\":\"Invalid OAuth token. The provided token was not found or is malformed.\"}}\n    at D6.generate (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1304:12612)\n    at gq.makeStatusError (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1321:2100)\n    at gq.makeRequest (file:///opt/homebrew/

Note: Error logs were truncated.

jackrobertscott avatar Jul 10 '25 00:07 jackrobertscott

Just ran into the same issue.

giswqs avatar Jul 10 '25 00:07 giswqs

I tried logout and deleted ~/.claude and ~/.claude.json, then login again. Still the same error.

giswqs avatar Jul 10 '25 00:07 giswqs

same error here, confirmed

gianlucamazza avatar Jul 10 '25 00:07 gianlucamazza

same here

daichi1207 avatar Jul 10 '25 00:07 daichi1207

same here

bigmasonwang avatar Jul 10 '25 00:07 bigmasonwang

same here

wbcian avatar Jul 10 '25 00:07 wbcian

same here;)

kimwest00 avatar Jul 10 '25 00:07 kimwest00

Same here. https://status.anthropic.com/ doesn't show outage.

Niqnil avatar Jul 10 '25 00:07 Niqnil

Good to see we're all here.

Chrrxs avatar Jul 10 '25 00:07 Chrrxs

can we open an issue for a better error message? I got panic

gianlucamazza avatar Jul 10 '25 00:07 gianlucamazza

Same problem。 what happend?

fuzihaofzh avatar Jul 10 '25 00:07 fuzihaofzh

Same here

sottenad avatar Jul 10 '25 00:07 sottenad

Same -- logged out/in, ran /doctor, restarted. issue remains

russellhtan avatar Jul 10 '25 00:07 russellhtan

Same here

TakashiAihara avatar Jul 10 '25 00:07 TakashiAihara

same here

ivan-velikanov avatar Jul 10 '25 00:07 ivan-velikanov

Same here. https://status.anthropic.com/ doesn't show outage.

Yes. A basic message there would have been helpful, that reduces the panic to be honest. Also a command line switch to see such status in claudecode would be nice. The login issues are horrible, somewhat reduces with proxies sometimes.

ivan-velikanov avatar Jul 10 '25 00:07 ivan-velikanov

same

MamaxYT avatar Jul 10 '25 01:07 MamaxYT

+1

bazsupport avatar Jul 10 '25 01:07 bazsupport

same here. /logout restarted machine , ran claude update /login

is911 avatar Jul 10 '25 01:07 is911

+1

RoryWatts avatar Jul 10 '25 01:07 RoryWatts