Repository navigation
Add OpenAI OAuth login and Codex Responses API provider - #51
Merged
Merged
Conversation
Port OpenAI Codex OAuth flow from OpenClaw. Enables ChatGPT Pro/Plus users to authenticate via browser instead of API keys, using their subscription (separate billing from API). OAuth flow: - PKCE authorization code flow with localhost:1455 callback - Browser auto-launch with manual URL paste fallback - JWT token decoding to extract chatgpt_account_id - Token refresh support - Secure credential storage (~/.pytoclaw/credentials.json, 0600) Codex Responses API provider: - Uses https://chatgpt.com/backend-api/codex/responses endpoint - Bearer token + account-id headers - Converts between internal message format and Responses API format - ChatGPT usage limit friendly error messages Onboarding updated: - OpenAI auth method choice: browser_login (default) or api_key - OAuth credentials stored securely, not in config.yaml - Factory auto-detects OAuth credentials for Codex provider 20 new tests (94 total passing). Fixes #50 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
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
openai-codex-oauth.ts. Opens browser toauth.openai.com, captures callback onlocalhost:1455, exchanges code for tokens. Supports manual URL paste for SSH/headless.chatgpt.com/backend-api/codex/responseswith Bearer token +chatgpt-account-idheader. Converts messages to Responses API format. Friendly ChatGPT usage limit error messages.~/.pytoclaw/credentials.json(0600 perms). Supports API key and OAuth credential types with auto-refresh.browser_login(default) orapi_key. OAuth tokens stored separately from config.yaml.Key constants (from OpenClaw)
app_EMoamEEZ73f0CkXaXp7hrannhttps://auth.openai.com/oauth/authorizehttps://auth.openai.com/oauth/tokenhttp://localhost:1455/auth/callbackhttps://chatgpt.com/backend-apiTest plan
pytoclaw onboard→ selectbrowser_login→ complete OAuth in browser~/.pytoclaw/credentials.jsoncreated with OAuth tokenspytoclaw agent→ verify Codex provider is usedFixes #50
🤖 Generated with Claude Code