Codex CLI Login Fails on Termux (Android) — Token Exchange Error

Resolved 💬 3 comments Opened Nov 13, 2025 by xhlsa Closed Jan 10, 2026

Bug Report: Codex CLI Login Fails on Termux (Android) — Token Exchange Error

Summary

Codex CLI on Termux (Android) consistently fails during the OAuth token exchange step.
The browser callback to localhost:1455 succeeds, but Codex errors when POSTing to:

https://auth.openai.com/oauth/token

This appears to be the same failure pattern reported on Linux/WSL, but occurring on Termux as well.

---

Environment

Device: Samsung Galaxy S23 Ultra

OS: Android 13

Shell: Termux (latest packages)

Codex CLI version: codex --version → (fill this in)

Install method:

cargo install --git https://github.com/openai/codex \
--tag rust-v0.50.0 \
codex-cli --force --locked

Rust version: (optional but helpful — rustc --version)

---

Steps to Reproduce

  1. Build and install Codex CLI on Termux using cargo.
  1. Run:

codex login

  1. Browser opens normally and authenticates successfully.
  1. Browser redirects back to:

http://localhost:1455/auth/callback

(This callback works.)

  1. Codex attempts token exchange and then fails consistently.

---

Observed Behavior

CLI prints:

Starting local login server on http://localhost:1455.
If your browser did not open, navigate to this URL to authenticate:
https://auth.openai.com/oauth/authorize?....
Token exchange error: error sending request for url (https://auth.openai.com/oauth/token)

This happens every time.

---

Network / TLS Verification

Connectivity and TLS appear correct.

From the same Termux session:

curl -v https://auth.openai.com/oauth/token

Returns:

{
"error": {
"message": "Invalid method for URL (GET /oauth/token)",
"type": "invalid_request_error",
"param": null,
"code": null
}
}

This confirms:

DNS works

HTTPS/TLS handshake succeeds

CA bundle is valid

Server is reachable

So the issue is not a Termux network or certificate problem.

---

What I Already Tried

Reinstalled Codex CLI via cargo

Deleted Codex state:

rm -rf ~/.codex

Re-ran codex login multiple times

Reinstalled ca-certificates & openssl in Termux

Verified TLS works with curl

Confirmed browser callback hits localhost:1455 successfully

The error always occurs at the same token-exchange step.

---

Expected Behavior

Codex CLI should successfully POST to:

https://auth.openai.com/oauth/token

and complete the login flow, as it does on desktop Linux/macOS.

---

Notes

This appears to match the open issues where Codex login fails on Linux/WSL with the exact same error:

Token exchange failed: error sending request for url (https://auth.openai.com/oauth/token)

Since Termux demonstrates identical behavior with working TLS, this may indicate an upstream issue in the CLI's token-exchange logic rather than a local environment misconfiguration.

---

Request

Could you confirm whether this is a known issue with the OAuth/token flow and whether Termux/Android is expected to be supported?

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗