Request: headless auth from vps
I cannot auth from vps
@ygit1 - I did just fine... try copying the url and pasting it into a local browser and then copy the failed redirect url and in another terminal (ssh) connection to the remote vps execute curl '<localhost_redirect_url>' or you could setup ssh port forwarding, but I find the curl fastest/easiest personally.
@ygit1 I'd recommend following the method @ben-vargas has suggested
I'd rather not add something yhe Codex CLI doesn't natively support
Safer to stay within bounds of the OpenAI T&Cs
@numman-ali - Well it has nothing to do about OpenAI T&Cs, they absolutely allow running codex cli on a remote dev server (linux, etc.). In fact, the example OAuth workflow I'd posted, and the opencode OAuth workflows, all normally support this. You should be able to copy the failed redirect URL (to localhost) into the CLI awaiting a URL and then the OAuth workflow should get the tokens - very common scenario for headless oauth.
I don't think it should be dismissed as a feature, but my approach is a workaround for now. The T&Cs are way back in the rearview mirror by spoofing to hit the backend-api already. 😂
That's very fair @ben-vargas ! I suppose, open to a PR if anyone wants to put it in
Yep, would be nice. It's not pretty but can confirm that @ben-vargas 's method works ..
- Get a second SSH window open on the same virtual machine
- then in the first terminal, run the auth
- click the link, sign in, and then it will redirect you to the local host that doens't work.
- copy the local host url and go to that 2nd terminal window you have open
- run curl "LOCALHOSTURL" and you should be good to go. Putting the url in quotes is important
Messy but at least it works
Yeah, it's a useful trick to know… I've had to do it on some of the major CLI tools like early claude code and codex as well before they added better support.