Codex login/Sign-in could not be completed Token exchange failed:

I can can not codex cli. Although I have plus account. Shows this error everytime I try to signin with chatgpt account.

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

Error codetoken_exchange_failed

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

Return to Codex to retry, switch accounts, or contact your workspace admin if access is restricted.

1 Like

Here is the solution.
Vscode extension may have some issues with login in browser sometimes. you can instead install nodejs with npm if not installed.

  • Install codex with npm i -g @openai/codex.
  • Write in terminal codex login.
  • Copy that link shown in terminal into browser if it doesnt redirect.
  • Login.
  • Restart VScode and it should be working.