-
Notifications
You must be signed in to change notification settings - Fork 19
✨ feat: Support Codex OAuth login flow instead of requiring API key #175
Copy link
Copy link
Open
Description
Summary
tapes start codex currently requires a service account API key (sk-svcacct-...) via tapes auth openai. This forces users off Codex's native OAuth login flow (codex login). We should support the OAuth flow so users can authenticate the way Codex intends.
Background
tapes start claude works seamlessly because Claude CLI uses a simple API key pattern — tapes stores the key, injects it as ANTHROPIC_API_KEY, and points ANTHROPIC_BASE_URL at the proxy. OpenAI/Codex doesn't follow this pattern — Codex CLI uses OAuth via codex login (through auth.openai.com), storing tokens in ~/.codex/auth.json.
Today, configureCodexAuth() in cmd/tapes/start/start.go:836-871:
- Requires an OpenAI API key from
~/.tapes/credentials.toml - Patches
~/.codex/auth.jsonto inject the API key - Strips OAuth tokens via
PatchCodexAuthKey()inpkg/credentials/codex.go:44(delete(auth, "tokens"))
This means users must have a service account key and can't use codex login.
What Needs to Change
1. pkg/credentials/codex.go — Stop stripping OAuth tokens
PatchCodexAuthKey()deletes the"tokens"field (line 44). Add a mode that preserves OAuth tokens, or split into two functions: one for API key patching, one for OAuth-aware mode.
2. cmd/tapes/start/start.go — Make configureCodexAuth() OAuth-aware
- If
~/.codex/auth.jsonalready has valid OAuth tokens (fromcodex login), skip the API key patching entirely. Just let the proxy forward the OAuth bearer tokens. - Remove the hard requirement for
tapes auth openaiwhen OAuth tokens exist. - Fallback chain: OAuth tokens → API key → error with instructions.
3. proxy/proxy.go — Verify OAuth path coverage
isOpenAIAuthPath()(line 736) already routes/oauth/*,/auth/*,/oauth2/*etc. toauth.openai.comviaresolveOpenAIAuthUpstream()(line 696).- Verify this covers all paths that
codex loginand token refresh use. May need to add token refresh endpoints if not already covered.
4. Proxy header passthrough — Already works
header.goalready passesAuthorizationheaders through transparently. OAuth bearer tokens will flow toapi.openai.comwithout changes.
Key Files
| File | What to change |
|---|---|
pkg/credentials/codex.go |
Preserve OAuth tokens instead of deleting them |
cmd/tapes/start/start.go (configureCodexAuth) |
Detect existing OAuth tokens, skip API key requirement |
proxy/proxy.go (isOpenAIAuthPath) |
Audit OAuth/token-refresh path coverage |
Acceptance Criteria
-
codex login+tapes start codexworks withouttapes auth openai -
tapes auth openai+tapes start codex(API key path) still works as fallback - OAuth token refresh flows through the proxy correctly
- Proxy still captures and stores conversation turns from OAuth-authenticated requests
References
- Codex app-server docs: https://developers.openai.com/codex/app-server
codex loginusesauth.openai.comfor OAuth
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels