1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! # openai-auth
//!
//! A Rust library for OpenAI/ChatGPT OAuth 2.0 authentication with PKCE support.
//!
//! This library provides both synchronous (blocking) and asynchronous (runtime-agnostic)
//! APIs for authenticating with OpenAI's OAuth 2.0 endpoints.
//!
//! ## Features
//!
//! - **Async API** (default): Runtime-agnostic async operations
//! - **Blocking API** (optional): Blocking operations, no async runtime required
//! - **PKCE Support**: Secure PKCE (SHA-256) authentication flow
//! - **Configurable**: Custom client IDs, endpoints, redirect URIs
//! - **Browser Integration**: Auto-open browser for authorization (default)
//! - **Callback Server**: Local server for automatic callback handling (optional, requires tokio)
//! - **JWT Utilities**: Extract ChatGPT account ID from access tokens
//! - **API Key Exchange**: Exchange id_token for OpenAI API key (Codex CLI flow)
//!
//! ## Quick Start (Async API)
//!
//! ```no_run
//! use openai_auth::{OAuthClient, OAuthConfig};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let client = OAuthClient::new(OAuthConfig::default())?;
//! let flow = client.start_flow()?;
//!
//! println!("Visit: {}", flow.authorization_url);
//! // Get code from user...
//!
//! let tokens = client.exchange_code("code", &flow.pkce_verifier).await?;
//! println!("Got tokens!");
//! Ok(())
//! }
//! ```
//!
//! ## Quick Start (Blocking API)
//!
//! ```no_run
//! use openai_auth::{blocking::OAuthClient, OAuthConfig};
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let client = OAuthClient::new(OAuthConfig::default())?;
//! let flow = client.start_flow()?;
//!
//! println!("Visit: {}", flow.authorization_url);
//! // Get code from user...
//!
//! let tokens = client.exchange_code("code", &flow.pkce_verifier)?;
//! println!("Got tokens!");
//! Ok(())
//! }
//! ```
// Public API exports
pub use ;
pub use ;
pub use OAuthClient;
pub use open_browser;
pub use ;