opencode-openai-codex-auth icon indicating copy to clipboard operation
opencode-openai-codex-auth copied to clipboard

Request: headless auth from vps

Open ydevx opened this issue 1 year ago • 6 comments

I cannot auth from vps

ydevx avatar Oct 05 '25 15:10 ydevx

@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.

ben-vargas avatar Oct 06 '25 02:10 ben-vargas

@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 avatar Oct 06 '25 05:10 numman-ali

@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. 😂

ben-vargas avatar Oct 06 '25 06:10 ben-vargas

That's very fair @ben-vargas ! I suppose, open to a PR if anyone wants to put it in

numman-ali avatar Oct 06 '25 08:10 numman-ali

Yep, would be nice. It's not pretty but can confirm that @ben-vargas 's method works ..

  1. Get a second SSH window open on the same virtual machine
  2. then in the first terminal, run the auth
  3. click the link, sign in, and then it will redirect you to the local host that doens't work.
  4. copy the local host url and go to that 2nd terminal window you have open
  5. run curl "LOCALHOSTURL" and you should be good to go. Putting the url in quotes is important

Messy but at least it works

ironbelly avatar Oct 09 '25 21:10 ironbelly

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.

ben-vargas avatar Oct 09 '25 23:10 ben-vargas