Setup: OpenClaw 2026.4.5 on Ubuntu/WSL2 (headless, no display). Running openclaw models auth login --provider openai-codex from an agent's exec tool (PTY mode).
What happens:
- The OAuth flow starts correctly — generates PKCE challenge, shows the authorize URL
- User opens the URL in their local browser, signs in, gets redirected to
localhost:1455/auth/callback?code=... - User pastes the redirect URL back into the PTY prompt
- The PTY session crashes before the token exchange completes
Error from gateway logs:
Unhandled promise rejection: Error: Agent listener invoked outside active run
Uncaught exception: Error: setRawMode EIO
at ReadStream.setRawMode (node:tty:81:24)
Attempted workarounds:
send-keyswith literal text (no Enter submitted)pasteaction with text + newline (session dies before exchange)- Tried multiple times with fresh OAuth codes — same crash every time
Environment:
- WSL2 (Windows Subsystem for Linux)
- No physical TTY — headless server
- OpenClaw browser config:
headless: true,noSandbox: true - Node v22.22.0
Question: Is there a non-interactive way to complete the OpenAI Codex OAuth flow? For example, a command that accepts the redirect URL or authorization code as a CLI argument instead of requiring an interactive PTY prompt? Or a way to manually write the OAuth tokens to auth-profiles.json after doing the PKCE exchange with curl?
OpenClaw version: 2026.4.5 (3e72c03)