Codex Cli/Desktop. Auth Failed with: token exchange failed

Subject: Codex authentication fails on macOS (CLI and Desktop), but works on Ubuntu with the same configuration

I’m experiencing an authentication issue that appears to be specific to macOS.

Environment

  • macOS Tahoe 26

  • Apple Silicon M5

  • Codex CLI 0.142.5 (installed via Homebrew)

  • Node.js v26.4.0

  • Codex Desktop App (latest ARM64 version downloaded from the official website)

  • ChatGPT account authentication

Problem

On macOS:

  • Codex Desktop fails to sign in with the error:

    • token exchange failed
  • Codex CLI fails with:

    • Error logging in with device code: error sending request for url (https://auth.openai.com/api/accounts/deviceauth/usercode)

The same ChatGPT account, the same Codex CLI version (0.142.5), and the same HTTPS proxy configuration work successfully on an Ubuntu machine.

Diagnostics already performed

  • Reinstalled the latest ARM64 Codex Desktop App.

  • Confirmed the application is the native ARM64 build.

  • Confirmed the codex:// URL scheme is correctly registered on macOS.

  • Reinstalled Codex CLI.

  • Tested both:

    • codex login

    • codex login --device-auth

  • Executed the native binary directly (bypassing the Node.js wrapper):

    • @openai/codex-darwin-arm64

    • The same error occurs.

  • Verified network connectivity:

    • curl successfully connects to https://auth.openai.com through the configured HTTPS proxy.

    • TLS handshake succeeds.

    • node fetch() also successfully reaches the endpoint.

  • The issue reproduces only with Codex on macOS.

Additional observations

The environment uses an HTTPS proxy configured in macOS System Settings.

The same proxy configuration works correctly on Ubuntu, where Codex CLI authenticates successfully using the same OpenAI account.

This suggests the issue may be specific to the macOS implementation of Codex authentication (CLI and Desktop), or to the HTTP client used by the native @openai/codex-darwin-arm64 binary.

Welcome to the forum!

You are welcome to discuss Codex issues on the forum, however the official place to report and track them is the GitHub issue tracker for OpenAI Codex.

I had ChatGPT look for the closest related issue and it identified:

The noted issue has some workarounds and other suggestions.

If that issue matches your problem, consider adding a :+1: reaction on the GitHub issue page itself, not just on the forum topic, as reactions on GitHub help the developers gauge impact and prioritize work.

If it is not the same issue, try searching the existing GitHub issues for a closer match. If you cannot find one, then open a new issue with as much detail as possible.