[BUG] OAuth access token not auto-refreshed on startup — forces re-login after every PC restart
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?
On Windows 11, Claude Code (VSCode extension) does not automatically refresh the OAuth access token when it has expired. Instead of silently refreshing using the stored refreshToken, it prompts the user to re-authenticate via browser on every session start.
- Environment:
OS: Windows 11 Enterprise
Claude Code: VSCode extension (v2.1.76)
Auth method: Claude.ai subscription (OAuth, not API key)
- Steps to reproduce:
Log in via claude login (browser OAuth flow completes successfully)
Use Claude Code normally
Wait for the access token to expire (~24h), or restart PC after expiry
Open VSCode — Claude Code prompts for re-authentication instead of using the refresh token
- Expected behavior:
Claude Code should detect that the accessToken in ~/.claude/.credentials.json is expired and silently use the refreshToken to obtain a new access token — without requiring user interaction.
- Actual behavior:
Claude Code throws a 401 error and forces a full re-login via browser, even though a valid refreshToken is present in ~/.claude/.credentials.json.
- Additional context:
~/.claude/.credentials.json correctly contains both accessToken, refreshToken, and expiresAt
No credentials are stored in Windows Credential Manager
~/.claude.json contains oauthAccount metadata but no token fields
The refreshToken is never consumed — it remains unchanged after forced re-login
What Should Happen?
Expected behavior:
Claude Code should detect that the accessToken in ~/.claude/.credentials.json is expired and silently use the refreshToken to obtain a new access token — without requiring user interaction.
Error Messages/Logs
Failed to authenticate. API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"OAuth token has expired. Please obtain a new token or refresh your existing token."},"request_id":"req_011....."
Steps to Reproduce
- Steps to reproduce:
Log in via claude login (browser OAuth flow completes successfully)
Use Claude Code normally
Wait for the access token to expire (~24h), or restart PC after expiry
Open VSCode — Claude Code prompts for re-authentication instead of using the refresh token
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
Claude 2.1.76 (VS Code extension)
Platform
Other
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗