fix: auth add openai-codex should import from ~/.codex/auth.json before device code#9284
fix: auth add openai-codex should import from ~/.codex/auth.json before device code#9284ASRagab wants to merge 1 commit into
Conversation
…re device code When running `hermes auth add openai-codex`, the command went straight to the device code flow without checking for existing Codex CLI credentials at ~/.codex/auth.json. This blocks users whose org/workspace has device code auth disabled — they have valid tokens from `codex login` (browser OAuth) but no way to get them into Hermes. The old `hermes login --provider openai-codex` (now removed) had this import step via `_login_openai_codex()`, but it was never carried over to the new `auth_add_command()` in auth_commands.py. Changes: - Check `_import_codex_cli_tokens()` before falling through to device code - Prompt user to confirm import (default: yes) - Fall through to device code if no CLI tokens found or user declines - Add 3 tests covering: import path, no-tokens fallback, user-declines fallback - Fix existing test_auth_add_codex_oauth_persists_pool_entry to isolate CODEX_HOME
|
Thanks for the submission @ASRagab. Closing as superseded — explicit import is now offered interactively via Hermes's Codex auth design was reworked in #12360 ("Hermes owns its own Codex auth; stop touching The valid adjacent fixes from this batch (error parsing, fallback chain on auth failure, reauth UX) landed together in #15104. |
Fixes #9283
Problem
hermes auth add openai-codexgoes straight to the device code flow without checking for existing Codex CLI credentials at~/.codex/auth.json. This blocks users whose org/workspace has device code auth disabled — they have valid tokens fromcodex login(browser OAuth) but no way to get them into Hermes.The old
hermes login --provider openai-codexhad this import step in_login_openai_codex(), but it was never carried over to the newauth_add_command()inauth_commands.py.Fix
_import_codex_cli_tokens()before falling through to device code inauth_add_command()test_auth_add_codex_oauth_persists_pool_entryto isolateCODEX_HOME(pre-existing test leak on machines with real~/.codex/auth.json)Test Results
All 4 codex-related auth_commands tests pass:
Note: 2 pre-existing
auth_removetests (test_auth_remove_accepts_label_target,test_auth_remove_prefers_exact_numeric_label_over_index) fail on machines with a real~/.codex/auth.jsondue to missingCODEX_HOMEisolation — this is a separate upstream issue not introduced by this change.