Add codex login --api-key (#1759)

Allow setting the API key via `codex login --api-key`
This commit is contained in:
pakrym-oai
2025-07-31 10:48:49 -07:00
committed by GitHub
parent 96654a5d52
commit 549846b29a
10 changed files with 218 additions and 46 deletions

View File

@@ -26,7 +26,7 @@ pub struct CodexConversation {
/// that callers can surface the information to the UI.
pub async fn init_codex(config: Config) -> anyhow::Result<CodexConversation> {
let ctrl_c = notify_on_sigint();
let auth = load_auth(&config.codex_home)?;
let auth = load_auth(&config.codex_home, true)?;
let CodexSpawnOk {
codex,
init_id,

View File

@@ -327,14 +327,14 @@ fn auth_from_token(id_token: String) -> CodexAuth {
AuthMode::ChatGPT,
PathBuf::new(),
Some(AuthDotJson {
tokens: TokenData {
openai_api_key: None,
tokens: Some(TokenData {
id_token,
access_token: "Access Token".to_string(),
refresh_token: "test".to_string(),
account_id: None,
},
last_refresh: Utc::now(),
openai_api_key: None,
}),
last_refresh: Some(Utc::now()),
}),
)
}