claude-code - 💡(How to fix) Fix [BUG] OAuth session expires mid-session with 401, /login doesn't reliably refresh [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#55932Fetched 2026-05-05 06:02:36
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Timeline (top)
labeled ×3commented ×1

Claude Code v2.1.126 + Claude Pro — OAuth session expires during active sessions and returns 401 for ALL commands, including /login itself and the /bug feedback mechanism.

Error Message

Please run /login · API Error: 401 {"error":{"type":"authentication_error","message":"Invalid authentication credentials"}} 4. Running /login again sometimes succeeds temporarily but token expires again shortly after

Root Cause

Claude Code v2.1.126 + Claude Pro — OAuth session expires during active sessions and returns 401 for ALL commands, including /login itself and the /bug feedback mechanism.

Code Example

Please run /login · API Error: 401
   {"error":{"type":"authentication_error","message":"Invalid authentication credentials"}}
4. Running `/login` again sometimes succeeds temporarily but token expires again shortly after
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Description

Claude Code v2.1.126 + Claude Pro — OAuth session expires during active sessions and returns 401 for ALL commands, including /login itself and the /bug feedback mechanism.

What Should Happen?

Running claude code in my console

Error Messages/Logs

Please run /login · API Error: 401
   {"error":{"type":"authentication_error","message":"Invalid authentication credentials"}}
4. Running `/login` again sometimes succeeds temporarily but token expires again shortly after

Steps to Reproduce

Steps to Reproduce

  1. Authenticate via /login (Pro subscription, OAuth flow)
  2. Use Claude Code normally for 10-20+ minutes
  3. Eventually all commands return: Please run /login · API Error: 401 {"error":{"type":"authentication_error","message":"Invalid authentication credentials"}}
  4. Running /login again sometimes succeeds temporarily but token expires again shortly after
  5. /bug feedback command also returns 401, making it impossible to report from within CLI

Expected

  • Session stays alive during active use, or /login reliably refreshes token
  • Feedback mechanism works even with expired auth

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

macOS · Claude Code v2.1.126 · Sonnet 4.6 · Claude Pro subscription

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

extent analysis

TL;DR

The OAuth session expiration issue in Claude Code v2.1.126 can be temporarily mitigated by re-running the /login command, although a more permanent fix is needed to prevent frequent token expirations.

Guidance

  • Investigate the authentication flow and token refresh mechanism to identify why the token expires prematurely, focusing on the OAuth session management in the Claude Code application.
  • Verify if the issue is specific to the Claude Pro subscription or if it affects other users as well, to determine the scope of the problem.
  • Check the Anthropic API documentation for any guidelines on handling token expirations and refreshing authentication sessions, as the issue might be related to the API's authentication mechanism.
  • Consider implementing a token refresh mechanism that automatically renews the authentication token when it is close to expiring, to prevent interruptions in the user's session.

Example

No specific code example can be provided without more details on the implementation, but the solution might involve modifying the authentication logic to handle token refreshes more effectively.

Notes

The issue seems to be a regression, as it worked in a previous version, indicating that a change in the code or the Anthropic API might be the cause. Without more information on the previous working version, it's challenging to pinpoint the exact cause.

Recommendation

Apply workaround: Given the regression nature and the impact on the user experience, applying a workaround such as automatically refreshing the token upon expiration or implementing a more robust session management system seems necessary until a permanent fix can be developed and deployed.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] OAuth session expires mid-session with 401, /login doesn't reliably refresh [1 comments, 2 participants]