forked from anomalyco/opencode
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add OpenAI Codex OAuth plugin (layer 1) #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implements built-in OAuth authentication for ChatGPT Plus/Pro subscribers to use OpenAI models via their existing subscription. Features: - PKCE OAuth flow with OpenAI's auth endpoints - Local callback server on port 1455 - Cross-platform browser launching - Automatic token refresh - Integrated as default plugin in opencode Based on: https://github.com/numman-ali/opencode-openai-codex-auth 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add api.responses.read and api.responses.write scopes to OAuth config to fix "Missing scopes: api.responses.write" error when using OpenAI API. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove api.responses.read/write scopes as they are not permitted by the Codex OAuth client. API access is implicit with the token. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The OAuth token works with chatgpt.com/backend-api, not api.openai.com. - Change base URL to https://chatgpt.com/backend-api - Use /codex/responses endpoint - Add required headers: OpenAI-Beta, originator, chatgpt-account-id - Extract account ID from JWT token claims 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add custom fetch that rewrites /responses to /codex/responses. The SDK sends requests to standard paths but Codex backend expects the /codex prefix. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…kend The Codex backend requires an 'instructions' field in the request body. Add request body transformation to include default instructions if not present. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…r instructions - Add store:false (required by ChatGPT backend) - Extract system message from input array to use as instructions - Improve default instructions text 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The Codex backend expects instructions starting with the Codex identification string "You are Codex, based on GPT-5..." 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add stream=true (required by Codex backend) - Strip item IDs from input array (stateless operation) - Remove system message from input after extracting to instructions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Embed the actual Codex system prompt from openai/codex repository. The backend validates instructions content. Source: https://github.com/openai/codex/blob/main/codex-rs/core/gpt_5_codex_prompt.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Delete instructions field entirely - backend validates strictly and uses model-specific defaults. Also remove system messages from input. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The external plugin has proper prompt alignment with the Codex backend. Use it as primary with built-in as fallback. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use external opencode-openai-codex-auth plugin instead, which has proper prompt alignment with the Codex backend. The built-in version was added but never worked correctly. Changes: - Remove packages/openai-codex-auth/ directory - Remove fallback logic in plugin loader - Update dependencies 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implements built-in OAuth authentication for ChatGPT Plus/Pro subscribers to use OpenAI models via their existing subscription.
Features
New Package
packages/openai-codex-auth/- Layer 1 built-in pluginUsage
opencode auth loginBased on: https://github.com/numman-ali/opencode-openai-codex-auth
Test plan
opencode auth loginshows the new option~/.opencode/data/auth.json🤖 Generated with Claude Code