[BUG] Auth session invalidated after sleep on macOS 26: background token refresh corrupts keychain credential instead of retaining old token

Open 💬 2 comments Opened Jun 27, 2026 by fliebe92

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?

claude auth status --text intermittently reports "Not logged in" throughout the day — including during active use, not just after overnight sleep. Re-running claude auth login restores the session temporarily. Did not occur on the same account on an older macOS version.

What Should Happen?

Session should not be destroyed that I can continue using Claude without the need to re-authenticate.

When a background token refresh fails, Claude Code should retain the existing credential and retry, not invalidate the stored session.

Error Messages/Logs

security find-generic-password -s "Claude Code-credentials" 2>/dev/null | grep "mdat\|cdat

"cdat" = "20260626092437Z"   ← last login
"mdat" = "20260627043751Z"   ← credential overwritten during failed refresh → session dead

Steps to Reproduce

  1. Use Claude during the day.
  2. Notice that after some time, the system asks if using the stored entry in the Keychain Access is fine. Even by clicking Always Allow, it asks again.

Sorry, no clear steps to reproduce are available.

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.181

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

The keychain entry (Claude Code-credentials) is not deleted — it still exists after the session dies. Its mdat timestamp is updated at the time the session becomes invalid, indicating Claude Code's background token refresh ran, failed, and wrote back an invalid state to the keychain instead of retaining the previously valid credential.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗