Skip to content

bug: codex signin with chatgpt doesnt work out of the box #440

Closed

Description

@Hyaxia

Agent Diagnostic

What The Issue Actually Is

This was not one single bug. It was a missing support path in OpenShell for a specific Codex auth flow:

  1. openshell sandbox create -- codex
  2. no OPENAI_API_KEY is available locally
  3. Codex falls back to browser-based ChatGPT login
  4. that login needs:
    • a localhost callback on port 1455
    • outbound HTTPS access to OpenAI auth endpoints from inside the sandbox

OpenShell handled neither of those automatically for Codex.

What I Found

In the repo, the Codex provider only supports the API-key path. It discovers OPENAI_API_KEY and injects it, but it does not model ChatGPT browser auth at all. See OpenShell/
crates/openshell-providers/src/providers/codex.rs.

That led to two concrete failures:

  • First failure: browser callback broke.
    • Codex inside the sandbox redirected the host browser to http://localhost:1455/...
    • the callback server was listening inside the sandbox, not on the host
    • OpenShell had not forwarded port 1455
    • result: ERR_CONNECTION_REFUSED
  • Second failure: token exchange broke.
    • after manually forwarding 1455, the callback reached Codex
    • then Codex tried to call https://auth.openai.com/oauth/token
    • the sandbox policy did not allow Codex’s outbound OpenAI traffic
    • result: token_exchange_failed

So the real issue is: OpenShell supported “Codex with provider-backed OPENAI_API_KEY”, but not “Codex launched in a sandbox, then authenticated interactively via ChatGPT browser
login”.

Why The Repo Behaved This Way

OpenShell’s policy system is binary-path + endpoint based. If the running binary and host are not allowed, the request is denied. That is expected behavior.

The gap was in sandbox create:

  • it inferred codex
  • it tried provider auto-creation
  • if no local API key existed, it basically just let Codex start
  • but it did not prepare the runtime for browser auth

That made the docs a little misleading: “configure it from inside the sandbox” was technically true, but incomplete for the ChatGPT login path.

Description

trying to sign in with chatgpt oauth doesnt work since there the networking configuration doesnt support it currently.

the issue can be solved manually by doing port forward to 1455 and adding the following policy:

  version: 1

  network_policies:
    codex_openai_auth:
      name: codex-openai-auth
      endpoints:
        - host: auth.openai.com
          port: 443
        - host: api.openai.com
          port: 443
      binaries:
        - path: /usr/local/bin/codex
        - path: /usr/bin/node

my agent is also able to solve it but I wont assume I know how you guys want to approach the solution here since it might be relevant for other providers as well. or maybe you dont want to solve it and its that way by design.
either way, I think the investigation i've provided here should be good enough for any future changes if needed.

cheers

Reproduction Steps

  1. run openshell sandbox create -- codex
  2. choose sign in with chatgpt
  3. put onetime password
  4. redirect fails

Environment

  • OS: Mac 15.7.4

Logs

Agent-First Checklist

  • I pointed my agent at the repo and had it investigate this issue
  • I loaded relevant skills (e.g., debug-openshell-cluster, debug-inference, openshell-cli)
  • My agent could not resolve this — the diagnostic above explains why

Activity

  1. github-actions commented on Mar 18, 2026

    @github-actions

    This issue appears to have been opened without an agent investigation.

    OpenShell is an agent-first project - please point your coding agent at the repo and have it diagnose this before we triage. Your agent can load skills like debug-openshell-cluster, debug-inference, openshell-cli, and generate-sandbox-policy.

    See CONTRIBUTING.md for the full workflow.

  2. Hyaxia commented on Mar 18, 2026

    @Hyaxia
    Author

    there's an agent investigation at the top of the issue, so thats incorrect :)

  3. johntmyers commented on Mar 18, 2026

    @johntmyers
    Collaborator

    Hi, thank you for reporting. I think the best approach for this may be to:

    1. Update the base policy with a codex rule. This will re-build the base image container.

    2. You could then forward the port when you launch the sandbox openshell sandbox create --forward 1455 -- codex.

    Please feel free to suggest a change to the base policy which should allow this to work better.

  4. johntmyers commented on Mar 19, 2026

    @johntmyers
    Collaborator

    Hi, since this can be solved with a base policy (or manual) update and port forwarding. I am going to close this issue. Feel free to open a PR on the base image in our community repo to add default codex policies.

  5. removed
    state:triage-neededOpened without agent diagnostics and needs triage
    on Oct 1, 2026
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

    wontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions