[BUG] OAuth access token expires after ~8 hours and refresh token is not used — requires full re-login every day (Windows 11)

Open 💬 3 comments Opened Jun 14, 2026 by Hulsmania

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?

Platform: Windows 11 Pro 10.0.26200
▎ Claude Code version: 2.1.167
▎ Auth method: Claude account with subscription (Pro)

▎ Describe the bug:
▎ Every morning when I open Claude Code, I receive API Error: 401 Invalid authentication credentials and am forced to run /login and complete the full OAuth flow again. This happens every single day without fail.

▎ Root cause identified:
▎ The ~/.claude/.credentials.json file contains both an accessToken and a refreshToken. The access token has an expiresAt timestamp of approximately 8 hours after creation. When that token expires, Claude Code does not use the stored refreshToken to obtain a new access token — instead it immediately surfaces a 401 and requires the user to go through the full OAuth browser flow again.

▎ Steps to reproduce:
▎ 1. Run /login using "Claude account with subscription"
▎ 2. Complete the OAuth flow successfully
▎ 3. Wait 8+ hours (or until the next morning)
▎ 4. Start Claude Code — immediately shows Please run /login · API Error: 401 Invalid authentication credentials

What Should Happen?

▎ Expected behavior:
▎ Claude Code should use the stored refreshToken to silently obtain a new accessToken when the current one expires, without requiring user interaction.

▎ Actual behavior:
▎ Claude Code ignores the refreshToken and forces a full re-login.

▎ Additional context:
▎ Also note: the browser does not auto-open during the /login flow on Windows — it falls back to displaying the URL manually. This is a separate issue but compounds the friction.

Error Messages/Logs

Steps to Reproduce

Steps to reproduce:
▎ 1. Run /login using "Claude account with subscription"
▎ 2. Complete the OAuth flow successfully
▎ 3. Wait 8+ hours (or until the next morning)
▎ 4. Start Claude Code — immediately shows Please run /login · API Error: 401 Invalid authentication credentials

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.167

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

Also note: the browser does not auto-open during the /login flow on Windows — it falls back to displaying the URL manually. This is a separate issue but compounds the friction.

View original on GitHub ↗

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