Skip to content

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

Open

Description

@BekishevYevgeniy

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://.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.
  3. Install and enable the OpenAI Codex extension.
  4. Click "Sign in" in the Codex extension.
  5. The browser opens the OAuth login page and authentication appears to succeed.
  6. After confirming access, the redirect goes to:
    http://localhost:1455/auth/callback?code=...
  7. Since the environment is remote (github.dev / Codespaces), localhost is not accessible.
  8. The authorization never completes and the Codex extension remains unauthenticated.

What is the expected behavior?

No response

Additional information

No response

Activity

  1. added
    extension
    on Nov 8, 2025
  2. added
    bug
    auth
    on Nov 8, 2025
  3. github-actions commented on Nov 8, 2025

    @github-actions
    Contributor
  4. lostcontrol commented on Dec 11, 2025

    @lostcontrol

    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

  5. lostcontrol commented on Dec 11, 2025

    @lostcontrol

    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.

    Image
  6. UnfixedMold commented on Feb 1, 2026

    @UnfixedMold

    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" }

  7. proyacerta commented on Feb 6, 2026

    @proyacerta

    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.

  8. LECOQQ commented on Feb 7, 2026

    @LECOQQ

    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:
    Image

    And authentication worked right after.

  9. debaedoma commented on Feb 26, 2026

    @debaedoma

    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

  10. pcfriek1987 commented on Mar 3, 2026

    @pcfriek1987

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

  11. ioachim-hub commented on Mar 21, 2026

    @ioachim-hub

    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.
  12. tritaum commented on Apr 11, 2026

    @tritaum

    Alternative straightforward workaround:

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

    then reload your workspace.

  13. ankur0101 commented on Apr 14, 2026

    @ankur0101

    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

  14. tritaum commented on Apr 14, 2026

    @tritaum

    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.

  15. tretretrer commented on May 6, 2026

    @tretretrer

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    authbugextension

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions