anthropics / anthropics/claude-code
Desktop app: OAuth session_stale_relogin latches and force-logs-out active sessions
- 主要言語
- Python
- スター
- 145k
- フォーク
- 23.1k
- PR マージ指標
- PR 指標を取得中
説明
**App**: Claude desktop app (macOS), version 1.49585.0
**OS**: macOS (Darwin 25.6.0)
## Summary
Claude Code sessions in the desktop app get force-logged-out because the OAuth token refresh flow fails with `invalid_grant`, and the subsequent fresh `/authorize` attempt is rejected by the server with `403 session_stale_relogin` ("sessionKey is valid but too old for the requested scope expansion"). This forces a full re-login even though the user had an active, valid login session.
## Observed behavior (from `~/Library/Logs/Claude/main.log`)
```
[info] [oauth] CLI requested token refresh after 401
[info] [oauth-v2] refreshing token for orgId=
[error] OAuth token refresh failed: status=400, response=
[info] [oauth-v2] refresh rejected (auth_error) for orgId=; tombstoning and falling through
[info] [oauth-v2] performing fresh /authorize for orgId=
[info] oauth failed: authorize returned 403
[info] oauth authorize rejected with session_stale_relogin; sessionKey is valid but too old for the requested scope expansion
[warn] [CCD CycleHealth] api_error (success): Failed to authenticate. API Error: 401 OAuth access token has expired. Re-authenticate to continue.
```
Once this fires, the failure "latches" — every session warm-up attempt short-circuits with the same `session_stale_relogin` error (`short-circuiting fresh /authorize on latched session_stale_relogin`) until it clears on its own several minutes later (`clearing latched session_stale_relogin failures`). In this occurrence it took about 8 minutes (06:00:04 → 06:08:40) and knocked out every active local session in the meantime.
I also found a much larger burst of the same `invalid_grant`/`session_stale_relogin` pair (~116 occurrences) in an older rotated log (`main4.log`, ~2026-08-22), suggesting this is a recurring issue rather than a one-off.
## What appears to be happening
The failing `/authorize` lookup requests a wider OAuth scope set (`user:inference user:file_upload user:profile user:sessions:claude_code`) than the existing `sessionKey` was granted under. It looks like an app update started requiring an additional scope, but the client doesn't proactively prompt for a fresh interactive login when this happens — it just keeps retrying silently, fails, and logs the user out with all their active local sessions torn down.
## Expected behavior
When the server determines the current `sessionKey` can't cover a newly-required scope, the client should prompt for a clean re-login immediately (or at least surface a clear "please sign in again" state) instead of latching into repeated silent-refresh failures that tear down active sessions for several minutes.
## Local factors ruled out
- System clock is in sync (~0.13s offset from Apple's time server) — not a clock-skew issue.
- App was already on the latest available build when this occurred.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
Start by reviewing ~/Library/Logs/Claude/main.log and the older main4.log for the invalid_grant and session_stale_relogin sequence. The issue names no repository files, tests, or entry points, so locate the desktop OAuth refresh and authorize handling before changing anything. Done should mean scope-expansion failures prompt a clear re-login without repeatedly latching or tearing down active sessions.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- macos
- 領域
- authentication, desktop, security
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 活発
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 35/100