Skip to main content

Crate codex_oauth

Crate codex_oauth 

Source
Expand description

PKCE OAuth login for OpenAI Codex.

Guides the user through a browser-based login against auth.openai.com and returns a Token that can be used as a Bearer token with the ChatGPT backend API (https://chatgpt.com/backend-api).

§Usage

#[tokio::main]
async fn main() -> Result<(), codex_oauth::Error> {
    let token = codex_oauth::login().await?;
    println!("{}", token.access_token);
    Ok(())
}

§Notes

  • Requires port 1455 to be free on localhost (hardcoded by OpenAI’s app registration).
  • CLIENT_ID is hardcoded to OpenAI’s public Codex app registration and is not configurable.

Structs§

Token
OAuth token returned after a successful login or refresh.

Enums§

Error

Functions§

login
Open a browser-based PKCE login flow and return the resulting OAuth token.
refresh
Exchange a stored refresh token for a new Token.