Skip to content

Add codex oauth support#138

Open
shuv1337 wants to merge 4 commits intoMirrowel:devfrom
shuv1337:main
Open

Add codex oauth support#138
shuv1337 wants to merge 4 commits intoMirrowel:devfrom
shuv1337:main

Conversation

@shuv1337
Copy link

Description

adds codex oauth multi-account support

Re-targeted from #137 (was against main, now against dev).

Testing Done

image image

Checklist

  • I have tested these changes locally
  • I have added license headers to new files (LGPL for library, MIT for proxy)
  • I have updated documentation (README/DOCUMENTATION.md) if needed
  • Related issue: #

- Add _extract_explicit_email_from_payload to prefer email claim over sub
- Prefer id_token explicit email over access_token sub for metadata
- Harden _find_existing_credential_by_identity to require both email and
  account_id to match when both are available (prevents workspace collisions)
- Fall back to single-field matching only when one side is missing
- Add tests for identity matching edge cases and setup_credential flows
gpt-5.3-codex returns 400 for max_output_tokens parameter.
Omit it and let the API use its default.
@shuv1337 shuv1337 requested a review from Mirrowel as a code owner February 17, 2026 10:15
@mirrobot-agent
Copy link
Contributor

Starting my review of this comprehensive OpenAI Codex OAuth multi-account support PR. With 27 files changed and over 5,500 lines added, this is a substantial feature addition. I'll be diving into the auth base implementation, provider integration, credential manager updates, and the new test suite. Will report back with detailed findings shortly.

@Mirrowel Mirrowel added enhancement New feature or request Agent Monitored Monitored for AI Agent to review PR's and commits Priority labels Feb 17, 2026
Copy link
Contributor

@mirrobot-agent mirrobot-agent bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall Assessment

This is a comprehensive and well-structured PR that adds OpenAI Codex OAuth multi-account support to the LLM-API-Key-Proxy. The implementation follows existing patterns in the codebase and includes:

  • Complete OAuth Authorization Code + PKCE flow implementation
  • File-based and environment variable credential support
  • First-run import from Codex CLI credentials
  • SSE translation for streaming responses
  • Comprehensive test suite (994 lines of tests across 5 test files)
  • Updated documentation (README, DOCUMENTATION.md, .env.example)

The code quality is generally high with good error handling, logging, and follows the existing architecture. The PR demonstrates solid engineering practices with proper separation of concerns between auth base, provider, and credential management.

Key Strengths

  1. Protocol Implementation: The SSE event translation (CodexSSETranslator) is thorough and handles multiple event types with proper fallback chains
  2. Testing: Good test coverage with 379 lines dedicated to auth tests alone, including JWT decoding, expiry logic, and env loading
  3. Documentation: All user-facing documentation has been updated consistently
  4. Integration: Clean integration with existing credential tool, settings UI, and launcher TUI

Suggestions for Improvement

  1. Security: The hardcoded OAuth client ID app_EMoamEEZ73f0CkXaXp7hrann in openai_codex_auth_base.py should be confirmed as intentionally public (it's a public client ID by design for OAuth flows, but should be documented)

  2. Async Task Handling: The _refresh_token method creates fire-and-forget tasks with asyncio.create_task() for re-auth queueing. These tasks are not awaited or tracked, which could lead to unhandled exceptions being silently dropped.

  3. Resource Management: Consider reusing httpx.AsyncClient instances rather than creating new ones per refresh attempt for better performance.

  4. Code Duplication: JWT decoding logic is duplicated between credential_manager.py and openai_codex_auth_base.py - consider extracting to a shared utility.

  5. Error Parsing: The parse_quota_error method uses substring matching that could have false positives - consider more specific patterns.

  6. TODOs: Two TODOs remain regarding quota window tuning (lines 376, 382 in provider) - acceptable for initial implementation but should be tracked.

Minor Notes

  • Architecture: The nested async generators in acompletion could be flattened for better readability
  • The deduplication logic in import methods could be refactored to reduce duplication
  • Consider adding stress tests for queue management concurrency paths

This PR is ready for merge. The suggestions above are improvements rather than blockers. Great work on this substantial feature addition!

This review was generated by an AI assistant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Agent Monitored Monitored for AI Agent to review PR's and commits enhancement New feature or request Priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants