You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OAuth refresh token not used when credentials are copied to remote/headless machines #21765
When copying ~/.claude/.credentials.json from an authenticated machine to a remote/headless machine, Claude Code throws a 401 authentication_error ("OAuth token has expired") instead of using the refreshToken present in the credentials file to obtain a new access token.
Steps to Reproduce
Authenticate Claude Code on a local workstation via claude login (Max subscription, OAuth flow)
Copy ~/.claude/.credentials.json to a remote headless machine (e.g., via scp)
Run claude on the remote machine after the accessToken has expired
Expected Behavior
Claude Code should detect the expired accessToken, use the refreshToken to obtain a new access token, and continue normally — the same way it does on the original machine.
Actual Behavior
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_011CXc8h3VFKY9jGum2N2rTZ"}
Credentials File Structure
The .credentials.json contains all necessary fields for a refresh:
The refreshToken is present but is not being used when the accessToken expires.
Use Case
Managing multiple headless Linux machines (Proxmox LXCs, Incus containers) where browser-based claude login is not practical. These machines are on a Tailnet and the intended workflow is to authenticate once on a workstation and distribute credentials to headless nodes. The copy-paste authorization code flow on headless machines is unreliable.
Environment
Source machine: Windows 11, Claude Code (Max subscription, OAuth)
Target machines: Headless Linux (Debian/Ubuntu LXCs and VMs)
Network: Tailscale mesh
Claude Code version: Latest (as of Jan 2026)
Reacted by Fahreddin Özcan, Thomas Bergheim, Lorenzo Wynberg, Charlie O'Hara, Bryan, Will and chumen77
Yes, I can confirm this is the issue. I've verified our refresh token flow to be working, however Claude Code doesn't use refresh tokens to get new access tokens, so users are forced to re-authenticate too often.
This issue stems from refresh token rotation (Claude uses this), which is a security best practice. When a client redeems a refresh token, the server invalidates it and issues a new one. As a result, two machines can’t share the same refresh token. One machine redeems it and stores the rotated token, while the other keeps using the old token and fails.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.
Activity
github-actions commentedon Jan 29, 2026
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
fahreddinozcan commentedon Jan 30, 2026
Yes, I can confirm this is the issue. I've verified our refresh token flow to be working, however Claude Code doesn't use refresh tokens to get new access tokens, so users are forced to re-authenticate too often.
lonetis commentedon Feb 28, 2026
This issue stems from refresh token rotation (Claude uses this), which is a security best practice. When a client redeems a refresh token, the server invalidates it and issues a new one. As a result, two machines can’t share the same refresh token. One machine redeems it and stores the rotated token, while the other keeps using the old token and fails.
github-actions commentedon Mar 28, 2026
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
github-actions commentedon Apr 6, 2026
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.