Skip to content

MCP OAuth reauth succeeds but active session still uses stale refresh token (invalid_grant) #14144

@vinzenz

Description

@vinzenz

Summary

After re-authenticating an OAuth-enabled MCP server, the currently running Codex agent/session can continue using a stale refresh token and still fail MCP initialization with invalid_grant until the app/session is restarted.

Expected behavior

After successful codex mcp login <server>, MCP handshakes in the active session should use fresh credentials immediately (or the runtime should force re-init of auth state).

Observed behavior

  • codex mcp login <server> reports success.
  • MCP tool calls in the same running session continue failing with:
    OAuth token refresh failed: invalid_grant: Invalid or expired refresh token
  • Restarting the app/new session clears the issue.

Steps to reproduce

  1. Configure any OAuth-enabled MCP server.
  2. Let its refresh token become invalid/expired.
  3. In a running Codex session, trigger MCP usage and observe invalid_grant failure.
  4. Run codex mcp login <server> and complete OAuth successfully.
  5. Retry MCP usage in the same running session.
  6. Observe continued invalid_grant until restart/new session.

Environment

  • Codex CLI: codex-cli 0.107.0
  • Platform: macOS 26.3.1 (25D2128)
  • Date observed: 2026-03-10

Notes

This appears to be runtime credential cache invalidation rather than OAuth login failure. A post-login cache refresh or MCP client reinitialization would likely resolve it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    authIssues related to authentication and accountsbugSomething isn't workingmcpIssues related to the use of model context protocol (MCP) servers

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions