codex - 💡(How to fix) Fix VS Code/Windsurf Codex extension stuck on infinite spinner — refresh_token_reused causes auth loop [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#19803Fetched 2026-04-28 06:36:51
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×3commented ×1cross-referenced ×1

Error Message

No error or re-auth prompt is shown in the UI at any point. "error": { Result: sidebar spins indefinitely. No re-auth prompt appears. No error is shown error from the backend, it should:

Root Cause

Root cause found in the extension log at: ~/.config/Code/logs/<session>/window1/exthost/openai.chatgpt/Codex.log

Fix Action

Fix / Workaround

Workaround (manual): rm ~/.codex/auth.json codex auth login

RAW_BUFFERClick to expand / collapse

What version of the IDE extension are you using?

openai.chatgpt-0.4.46-linux-x64 (Codex – OpenAI's coding agent) Codex CLI version: 0.125.0

What subscription do you have?

Plus

Which IDE are you using?

VS Code and Windsurf

What platform is your computer?

Linux 6.8.0-110-generic x86_64 x86_64

What issue are you seeing?

The Codex sidebar shows an infinite loading spinner and never becomes usable. No error or re-auth prompt is shown in the UI at any point.

Root cause found in the extension log at: ~/.config/Code/logs/<session>/window1/exthost/openai.chatgpt/Codex.log

Key errors (repeating in a tight loop):

[CodexMcpConnection] cli: Failed to refresh token: 401 Unauthorized: { "error": { "message": "Your refresh token has already been used to generate a new access token. Please try signing in again.", "type": "invalid_request_error", "code": "refresh_token_reused" } }

codex_models_manager: failed to refresh available models: token_invalidated url: https://chatgpt.com/backend-api/codex/models

rmcp::transport::worker: worker quit with fatal: Transport channel closed — token_invalidated (401)

The extension retries authentication in an infinite loop and never surfaces a "Sign in again" prompt to the user. The only fix is to manually delete ~/.codex/auth.json and run codex auth login — there is no in-app recovery path.

Secondary (unrelated) noise also loops in the log: "unsupported feature enablement workspace_dependencies: currently supported features are apps, memories, plugins, tool_search, tool_suggest, tool_call_mcp_elicitation"

What steps can reproduce the bug?

  1. Have the Codex extension installed and authenticated (working state).
  2. Sign in to your OpenAI/ChatGPT account from a second device or browser session — this invalidates the refresh token stored locally in ~/.codex/auth.json.
  3. Reopen VS Code or Windsurf.
  4. Open the Codex sidebar.

Result: sidebar spins indefinitely. No re-auth prompt appears. No error is shown in the UI. The extension silently retries the invalidated token in a loop.

What is the expected behavior?

When the extension receives a 401 token_invalidated or refresh_token_reused error from the backend, it should:

  1. Stop retrying immediately.
  2. Show a visible "Your session has expired — Sign in again" prompt in the sidebar.
  3. On click, trigger the OAuth re-authentication flow.

Currently none of this happens — the failure is completely silent to the user.

Additional information

Workaround (manual): rm ~/.codex/auth.json codex auth login

This restores functionality immediately after re-authentication.

The issue appears to be triggered specifically when a token rotation occurs from another session (e.g. logging in on a second machine), making the locally cached refresh token stale. The extension has no mechanism to detect or recover from this state without manual intervention.

Related community threads reporting the same symptom:

extent analysis

TL;DR

The Codex extension gets stuck in an infinite loading loop due to a stale refresh token, and a manual workaround is to delete the ~/.codex/auth.json file and re-authenticate using codex auth login.

Guidance

  • The issue is caused by the extension retrying an invalidated token in a loop without surfacing a re-auth prompt, so a potential fix would involve modifying the extension to stop retrying immediately upon receiving a 401 error and display a "Sign in again" prompt.
  • To verify the issue, check the extension log for repeating errors indicating a refresh_token_reused or token_invalidated error.
  • The manual workaround of deleting ~/.codex/auth.json and re-authenticating using codex auth login can be used to restore functionality.
  • The extension's authentication mechanism may need to be updated to handle token rotation and invalidation more robustly.

Example

No code snippet is provided as the issue is related to the extension's behavior and authentication mechanism, which is not explicitly described in the issue.

Notes

The issue appears to be specific to the Codex extension and its handling of token rotation and invalidation. The provided workaround is a temporary solution, and a more permanent fix would require updates to the extension's authentication mechanism.

Recommendation

Apply workaround: deleting ~/.codex/auth.json and re-authenticating using codex auth login, as this is the only provided solution that restores functionality immediately after re-authentication.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING