OAuth session expires mid-session and fails to auto-refresh, requiring manual /login

Status Open
Reported on v2.1.241
Maintainer reply None cached
Activity 1 comment · opened Aug 25, 2026

Description

Mid-session, the Claude Code CLI's OAuth token silently expires and every request fails with:

Failed to authenticate: OAuth session expired and could not be refreshed

The only recovery is running /login again manually. This has happened at least twice, in two different process contexts:

  1. Inside a Supacode-managed pane (zmx attachlogin -flp → zsh), on claude 2.1.241.
  2. Inside a plain Terminal.app → zsh → claude daemon run background session, on claude 2.1.245 — no Supacode/zmx involved at all.

This suggests the bug is in the daemon's own proactive-refresh scheduling, not tied to any particular terminal wrapper.

Evidence

~/.claude/daemon.log shows the daemon scheduling its next proactive refresh many hours out, while the credentials file (~/.claude/.credentials.json) gets rewritten (i.e. the token actually expires / gets replaced by manual /login) well before that scheduled time — with no refresh attempt or failure logged in between:

[2026-08-25T09:54:39.394Z] [supervisor] auth: scheduling proactive refresh in 28202s

Daemon started 09:54:39 UTC (11:54 CEST), next refresh scheduled ~7.8h later (~19:44 CEST). But the credentials file was rewritten at 12:12 CEST (via manual /login after a failure) — about 2 hours after daemon start, hours before the scheduled proactive refresh. Nothing in the log shows a refresh attempt or failure in between; the token just silently died and the session errored out until manual re-login.

A similar failure was captured in a Supacode pane on 2026-08-24 17:16:21 (version 2.1.241):

Failed to authenticate: OAuth session expired and could not be refreshed

claude --version: 2.1.241 (Claude Code)

Expected behavior

The daemon's proactive refresh should fire before the token actually expires, or the CLI should transparently retry/refresh on a 401 instead of hard-failing the in-progress request and requiring a manual /login.

Environment

  • claude --version: 2.1.245 (also reproduced on 2.1.241)
  • OS: macOS (Darwin 25.3.0)
  • Both native Terminal.app sessions and Supacode-managed panes affected

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗