pub struct AuthSessionHelper { /* private fields */ }Expand description
Helper for checking Codex auth state and triggering login flows with an app-scoped CODEX_HOME.
All commands run with per-process env overrides; the parent process env is never mutated.
Implementations§
Source§impl AuthSessionHelper
impl AuthSessionHelper
Sourcepub fn new(app_codex_home: impl Into<PathBuf>) -> Self
pub fn new(app_codex_home: impl Into<PathBuf>) -> Self
Creates a helper that pins CODEX_HOME to app_codex_home for every login call.
Sourcepub fn with_client(client: CodexClient) -> Self
pub fn with_client(client: CodexClient) -> Self
Wraps an existing CodexClient (useful when you already configured the binary path).
Sourcepub fn client(&self) -> CodexClient
pub fn client(&self) -> CodexClient
Returns the underlying CodexClient.
Sourcepub async fn status(&self) -> Result<CodexAuthStatus, CodexError>
pub async fn status(&self) -> Result<CodexAuthStatus, CodexError>
Reports the current login status under the configured CODEX_HOME.
Sourcepub async fn ensure_api_key_login(
&self,
api_key: impl AsRef<str>,
) -> Result<CodexAuthStatus, CodexError>
pub async fn ensure_api_key_login( &self, api_key: impl AsRef<str>, ) -> Result<CodexAuthStatus, CodexError>
Logs in with an API key when logged out; otherwise returns the current status.
Sourcepub async fn ensure_chatgpt_login(&self) -> Result<Option<Child>, CodexError>
pub async fn ensure_chatgpt_login(&self) -> Result<Option<Child>, CodexError>
Starts the ChatGPT OAuth login flow when no credentials are present.
Returns Ok(None) when already logged in; otherwise returns the spawned login child so the
caller can surface output/URLs. Dropping the child kills the login helper.
Sourcepub fn spawn_chatgpt_login(&self) -> Result<Child, CodexError>
pub fn spawn_chatgpt_login(&self) -> Result<Child, CodexError>
Directly spawns the ChatGPT login process.
Sourcepub async fn login_with_api_key(
&self,
api_key: impl AsRef<str>,
) -> Result<CodexAuthStatus, CodexError>
pub async fn login_with_api_key( &self, api_key: impl AsRef<str>, ) -> Result<CodexAuthStatus, CodexError>
Directly logs in with an API key without checking prior state.
Trait Implementations§
Source§impl Clone for AuthSessionHelper
impl Clone for AuthSessionHelper
Source§fn clone(&self) -> AuthSessionHelper
fn clone(&self) -> AuthSessionHelper
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more