Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Why my saved Claude Code logins kept dying, and the switcher I built around it

说明与用途

claude-switch 自动管理 Claude Code 的 OAuth 令牌,实现多账户切换,避免令牌失效。

问题

Claude Code logins become invalid after a single use of the refresh token, causing sessions to expire when switching accounts.

结果

The tool keeps the most recent login, respects OAuth single-use tokens, uses locks to avoid race conditions, and warns when a login is dead, enabling seamless switching between multiple Claude accounts.

工作流

  • 1. Install claude-switch via pipx. 2. Save the current account with claude-switch save <name>. 3. Add a new account with claude-switch add <name> and authenticate via browser. 4. Save the new account. 5. List accounts with claude-switch list. 6. Switch accounts with claude-switch use <name> or claude-switch auto. 7. Continue conversation in an open session by exiting and restarting Claude with claude -c.

证据

Claude Code signs in with OAuth. It holds a short-lived access token, about 8 hours, and a refresh token. When the access token runs out, Claude Code trades the refresh token for a new pair and writes both back.

来源

The server accepts each refresh token once. After a renewal, the old one is dead.

来源

claude-switch keeps one Claude Code profile and swaps only the login.

来源

It takes Claude Code's own locks during the swap, in the same order Claude Code takes them, so no running session renews or rewrites the login halfway through.

来源

It refuses to file one account's login under another name. It compares logins by a SHA-256 hash of the refresh token and by the email Claude Code records.

来源

  • 记录日期: 2026-11-02T21:14:03.129Z