Support OAuth token registration fails during automated provisioning
Description
When provisioning a new instance with OpenAI Codex CLI pre-installed via automated SSH-based tooling, the OAuth token registration does not work non-interactively. The token must be manually registered by SSHing into the instance and running the auth flow interactively, which breaks fully automated deployment pipelines.
Steps to Reproduce
- Deploy a new cloud instance (e.g., AWS Lightsail, DigitalOcean) with Codex CLI installed
- Attempt to register the OAuth token via SSH (non-interactive):
``bash``
ssh user@instance "codex auth login --api-key $OPENAI_API_KEY"
- The auth command either hangs waiting for interactive input, or silently fails to persist credentials
Expected Behavior
There should be a non-interactive way to register/provision OAuth tokens or API keys, e.g.:
codex auth login --api-key <KEY> --non-interactive
# or
codex auth set-token <KEY>
# or via environment variable
export OPENAI_API_KEY=<KEY>
Actual Behavior
OAuth registration requires an interactive terminal (TTY). In automated provisioning (SSH commands without TTY allocation), the token registration fails. The only workaround is to manually SSH into the instance and run the auth flow interactively.
Environment
- Codex CLI version: latest (via npm)
- OS: Ubuntu 22.04 (AWS Lightsail / DigitalOcean / BytePlus)
- Node.js: v22.x
- Provisioning context: automated SSH (non-interactive, no TTY)
Use Case
We run a deployment CLI (clawmacdo) that provisions cloud instances with Codex, Claude Code, and Gemini CLI pre-installed. All other tools support non-interactive token setup, but Codex requires manual intervention, preventing fully automated deployments.
Suggested Solution
Support one of:
- A
--non-interactiveflag on the auth command - A
set-token/set-api-keysubcommand that writes credentials directly - Reading
OPENAI_API_KEYfrom environment and persisting it on first run
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗