Skip to content

Rotation gateway triggers mass OAuth token invalidation across accounts #495

@bre01

Description

@bre01

Description

Using codex-multi-auth's rotation gateway (localhost proxy) triggers OpenAI's anti-abuse detection, causing OAuth tokens to be invalidated across multiple accounts. The gateway's account-switching pattern — rapidly rotating between different account tokens from the same IP/device — appears to be detected by OpenAI as suspicious activity.

Environment

  • macOS Sequoia
  • codex-multi-auth (latest)
  • 4 accounts configured (3 Gmail, 1 Outlook)
  • Rotation gateway enabled

Observed Behavior

After using Codex CLI through the rotation gateway for a period, accounts progressively get their tokens invalidated:

$ codex-multi-auth check

  ✓ Account 1 (...@gmail.com) | signed in and working
      (live check failed: Encountered invalidated oauth token for user, failing request)
  ✓ Account 2 (...@gmail.com) | signed in and working
      (live check failed: {"detail":"The 'gpt-5-codex' model is not supported ..."})
  ✓ Account 3 (...@gmail.com) | live session OK (5h 26% | 7d 10%)
  ✓ Account 4 (...@outlook.com) | signed in and working
      (live check failed: Your authentication token has been invalidated.)

Result: 4 working | 0 need re-login | 3 warnings

Accounts that were working fine before gateway usage get invalidated one by one. Re-logging in temporarily fixes it, but the token gets invalidated again once the gateway routes a request through that account.

Additional observations

  • Account 4 (Outlook/Microsoft SSO): Especially affected — token gets invalidated immediately after every re-login on the first request. This is reproducible and persistent. The account works fine on ChatGPT web.
  • Account 1 (Gmail): Was working, then invalidated after gateway usage.
  • Account 2: Separate issue — account plan doesn't support gpt-5-codex model.
  • Using codex-multi-auth switch <index> directly (without the gateway) does not seem to cause this issue.

Possible Cause

The rotation gateway rapidly switches between different OAuth tokens from the same IP/device. OpenAI's backend likely detects this pattern — multiple distinct user sessions originating from the same source in quick succession — and invalidates the tokens as a security measure.

Suggestions

  1. Increase minimum rotation interval — avoid switching accounts too frequently; add configurable cooldown between rotations
  2. Session affinity — keep using the same account for a longer period before rotating (e.g., stick with one account until it's actually rate-limited)
  3. Investigate Microsoft/Outlook SSO — Account 4's immediate invalidation on every single request may indicate a separate issue with how Microsoft-linked OAuth tokens are handled through the proxy
  4. Document the risk — warn users that aggressive rotation may trigger OpenAI's anti-abuse detection

Workaround

Disable the rotation gateway and use switch to manually select accounts:

codex-multi-auth rotation disable
codex-multi-auth switch 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions