Unable to complete OAuth login for Codex extension when using github.dev / Codespaces (redirect to localhost fails)

Open 💬 13 comments Opened Nov 8, 2025 by BekishevYevgeniy
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of the VS Code extension are you using?

0.4.37

What subscription do you have?

ChatGPT Plus (Codex access enabled)

Which IDE are you using?

GitHub Codespaces (browser-based VS Code) at https://miniature-broccoli-7wp9vx6xq64hrv6r.github.dev/

What platform is your computer?

Running inside GitHub Codespaces (Linux container, VS Code Web) Local client OS: macOS

What issue are you seeing?

I am trying to sign in to the OpenAI Codex VS Code extension inside GitHub Codespaces (browser-based VS Code environment). The authorization flow starts, but the redirect URL always returns to:

http://localhost:1455/auth/callback?code=...&scope=openid+profile+email+offline_access

Since Codespaces is a remote cloud environment and does not expose localhost ports to my browser environment, the extension cannot complete the OAuth exchange and therefore I cannot log in or use Codex.

Expected behavior:
The extension should detect remote environments such as github.dev / Codespaces and use a web-based redirect URI (e.g. https://<workspace>.app.github.dev/ or device_code grant) instead of localhost:1455.

Actual behavior:
OAuth redirect tries to reach local machine localhost, which is not accessible in a remote development environment. As a result, authentication never completes.

What I need:
Guidance on how to authenticate Codex inside github.dev / Codespaces. Is there an official supported redirect URI or alternative login flow (e.g. device code auth or manual API token provisioning)?

Environment:

  • GitHub Codespaces (browser VS Code)
  • Codex extension
  • Remote VS Code Web client
  • No access to localhost of the remote environment

What steps can reproduce the bug?

  1. Open any repository on GitHub.
  2. Press . to open the repository in github.dev (browser-based VS Code)

or open it inside GitHub Codespaces.

  1. Install and enable the OpenAI Codex extension.
  2. Click "Sign in" in the Codex extension.
  3. The browser opens the OAuth login page and authentication appears to succeed.
  4. After confirming access, the redirect goes to:

http://localhost:1455/auth/callback?code=...

  1. Since the environment is remote (github.dev / Codespaces), localhost is not accessible.
  2. The authorization never completes and the Codex extension remains unauthenticated.

What is the expected behavior?

_No response_

Additional information

_No response_

View original on GitHub ↗

13 Comments

github-actions[bot] contributor · 8 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #5673
  • #4602
  • #4562
  • #5668
  • #6393

Powered by Codex Action

lostcontrol · 7 months ago

Similar issue when using Dev Containers (VSCode server inside a Docker container) for a few days. Unable to log in, the redirect points to localhost:1455, which is not forwarded by the container. Login worked perfectly fine in the same environment a few days ago.

Version: 1.107.0
Commit: 618725e67565b290ba4da6fe2d29f8fa1d4e3622
Date: 2025-12-10T07:43:47.883Z
Electron: 39.2.3
ElectronBuildId: 12895514
Chromium: 142.0.7444.175
Node.js: 22.21.1
V8: 14.2.231.21-electron.0
OS: Linux x64 6.8.0-88-generic

Name: Codex – OpenAI’s coding agent
Id: openai.chatgpt
Description: Codex is a coding agent that works with you everywhere you code — included in ChatGPT Plus, Pro, Business, Edu, and Enterprise plans.
Version: 0.4.50
Publisher: OpenAI
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=openai.chatgpt

lostcontrol · 7 months ago

Solved it for Dev Containers. It seems VSCode/Docker exported 1455 to 1456 on my machine. I edited the port to 1455 and was able to log in again.

<img width="1405" height="146" alt="Image" src="https://github.com/user-attachments/assets/7edd1af3-6dc3-4d5e-85af-46d27d575ba4" />

UnfixedMold · 5 months ago

In my case I had two separate devcontainers running at once. As @lostcontrol pointed out, port missmatch is the core issue. Codex always expects port 1455 for auth (on the host). In a multi-devcontainer setup, the first codex instance on the first container takes up port 1455, and the other instances are forced to default to 1456, 1457, etc. and the auth fails.

The solution I've came up is to to just store creds on the host, outside of devcontainers and to avoid multi login on each container whatsoever


"mounts": [
"type=bind,source=${localEnv:HOME}/.codex-shared,target=/codex"
],
"remoteEnv": {
"CODEX_HOME": "/codex"
}

proyacerta · 5 months ago

The latest version of Codex extension is even more broken than before in Codespace. Before, it would try to complete the authentication process using localhost. You could substitute the host by doing a port export in Codespace. Now the extension just keeps spinning on start-up.

LECOQQ · 5 months ago

Got the same issue. Been using Cursor to code on a remote computer (w/ the remote ssh extension). Couldn't auth into Codex. Issue was indeed the port 1455 forwarded to 1456. ChatGPT solved it by adding to my .ssh file:

Host ur-remote-computer
  HostName x.x.x.x
  User ur-user
  LocalForward 1455 127.0.0.1:1455

You can then reconnect and verify to the ports tab:
<img width="1201" height="33" alt="Image" src="https://github.com/user-attachments/assets/f518898d-7a43-4210-97f3-44d018995e13" />

And authentication worked right after.

debaedoma · 4 months ago

Using your OpenAI API key would be a better alternative, if you have one. This is the approach I used:

  • Fund your OpenAI account with maybe $5
  • Create and copy your API key from the OpenAI Platform dashboard
  • In Codex, select API Key as the authentication option and paste the key in there.
  • Voila, you'll have full access to the Codex.

Note: You'll need to fund your account on the OpenAI Platform dashboard for this to work, and it's billed from your API balance on a pay-as-you-go basis, not your ChatGPT subscription

pcfriek1987 · 4 months ago

It's not actually, if you login to the api it's on usage base with account on subscription base.

ioachim-hub · 4 months ago

Authentication Workaround Steps

  • Start Login: Click Sign in and keep the new tab open.
  • Check Port: Look at the VS Code Server tab for the localhost port request.
  • Set Forwarding: Map that localhost port to your GitHub dev tunnel URL.
  • Complete authentication which will lead to a callback on localhost.
  • Copy Path: In the authentication tab, copy everything in the URL starting from the first slash (e.g., /auth/callback...).
  • Merge URLs: Paste that path directly onto the end of your tunnel URL.
  • Example: https://[TUNNEL-ID].devtunnels.ms/auth/callback...
  • Finalize: Open this combined URL in your browser to complete the process.
tritaum · 3 months ago

Alternative straightforward workaround:

npm install -g @openai/codex
codex login --device-auth

__then reload your workspace.__

ankur0101 · 3 months ago
Alternative workaround: `` npm install -g @openai/codex codex login --device-auth codex `` then reload your workspace.

But the prompting is limited to CLI and right pane based chat does not work

tritaum · 3 months ago
> Alternative workaround: > `` > npm install -g @openai/codex > codex login --device-auth > codex > `` > > > > > > > > > > > > then reload your workspace. But the prompting is limited to CLI and right pane based chat does not work

It does work, have you tried restarting your workspace? Codex CLI shares authentication with the Codex Extension.

tretretrer · 2 months ago

I spent way to much time trying to login...
Incredible how every step of the way there is something dumb happening :
Using the Normal sign in : same issue described above
I tried codex login --device-auth
But https://auth.openai.com/codex/device would prompt me for the code, but it expect only Numbers, and need to enter a code with letters

I tried https://auth.openai.com/api/accounts/deviceauth/authorize
It showed :
Enable device code authorization for Codex in ChatGPT Security Settings, then run "codex login --device-auth" again.

I did that, reloaded , and it worked.

Holly balls...