Codex ChatGPT auth should inject host access token via egress #109
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Codex bottles using ChatGPT/device login can reach
chatgpt.comafter adding the host to egress, but requests tochatgpt.com/backend-api/codex/...still return 403. The egress proxy strips agent-originatedAuthorizationheaders and only re-injects auth for routes that declare an egress-owned token. A barechatgpt.comroute therefore forwards Codex requests without the ChatGPT bearer token.Proposed fix
Use host-authorized Codex auth as the source of truth, but keep the token out of the agent container:
codex login --device-authon the host.~/.codex/auth.jsonon the host and extract onlytokens.access_token.chatgpt.comas an authenticated egress route, e.g.auth_scheme: Bearerwith anEGRESS_TOKEN_Nslot.Authorizationheader and inject the host-derived bearer forchatgpt.com.This mirrors the Claude egress-owned auth shape while avoiding copying
~/.codex/auth.jsonor refresh credentials into the agent.Caveats / follow-up
tokens.access_tokenexpires, so the minimal version may require restarting the bottle after host Codex refreshes auth.chatgpt.comroute preserves existing route auth, and newEGRESS_TOKEN_Nslots do not automatically receive env values in the running sidecar.Acceptance criteria
chatgpt.com/backend-api/codex/...through egress without forwarding any agent-held auth token.OPENAI_API_KEY,CODEX_ACCESS_TOKEN,tokens.access_token,tokens.refresh_token, orauth.json.Should require an explicit "forward_host_credentials" flag in the agent_provider manifest for this to happen, but otherwise looks good
Agreed. I would make
agent_provider.forward_host_credentialsan explicit opt-in gate for this path. Default stays false, so a Codex bottle can still use device login interactively, but bot-bottle will not read~/.codex/auth.jsonor forward any host-derived token unless the bottle declares that intent.That gives the implementation a clean policy shape:
agent_provider.template: codexalone does not forward host auth material.agent_provider.forward_host_credentials: truepermits the launcher to read host Codex auth, validate it is ChatGPT auth with a fresh access token, and place only the access token in the egress sidecar env.auth.json, refresh tokens, or access-token env vars.codex login --device-authon the host.I would add that flag to the issue acceptance criteria before implementing.