pub struct CodexOAuth { /* private fields */ }Expand description
Codex OAuth endpoints and refresh coordination. Clones share the singleflight table.
Implementations§
Source§impl CodexOAuth
impl CodexOAuth
pub fn new(client: Client) -> Self
Sourcepub fn with_endpoints(
client: Client,
token: &str,
usercode: &str,
device_token: &str,
) -> Self
pub fn with_endpoints( client: Client, token: &str, usercode: &str, device_token: &str, ) -> Self
Explicit endpoints for local mocks. Never derived from credential metadata.
Sourcepub fn with_siwc_token_url(self, url: &str) -> Self
pub fn with_siwc_token_url(self, url: &str) -> Self
The Sign in with ChatGPT token endpoint, for local mocks.
Sourcepub fn with_retry_delay(self, delay: Duration) -> Self
pub fn with_retry_delay(self, delay: Duration) -> Self
Tests shorten Go’s 1s-per-attempt refresh backoff.
Sourcepub fn with_client(&self, client: Client) -> Self
pub fn with_client(&self, client: Client) -> Self
The same endpoints and refresh table over another client: Go builds the refresh
client per credential from its effective proxy (NewCodexAuthWithProxyURL).
Sourcepub async fn exchange(
&self,
code: &str,
redirect: &str,
verifier: &str,
) -> Result<Tokens, ExecError>
pub async fn exchange( &self, code: &str, redirect: &str, verifier: &str, ) -> Result<Tokens, ExecError>
ExchangeCodeForTokensWithRedirect.
Sourcepub async fn refresh(&self, refresh_token: &str) -> Result<Tokens, ExecError>
pub async fn refresh(&self, refresh_token: &str) -> Result<Tokens, ExecError>
RefreshTokensWithRetry(ctx, token, 3), single-flighted per refresh token and
detached from the caller so a cancelled request cannot strand a rotated token.
Sourcepub async fn refresh_siwc(
&self,
refresh_token: &str,
client_id: &str,
device_id: &str,
) -> Result<Tokens, ExecError>
pub async fn refresh_siwc( &self, refresh_token: &str, client_id: &str, device_id: &str, ) -> Result<Tokens, ExecError>
RefreshSIWCTokensWithRetry(ctx, token, client, device, 3): the siwc
partition’s refresh grant, single-flighted per client ID and refresh token.
Sourcepub async fn device_code(&self) -> Result<DeviceCode, ExecError>
pub async fn device_code(&self) -> Result<DeviceCode, ExecError>
Requests a device code (requestCodexDeviceUserCode).
Sourcepub async fn device_poll(
&self,
code: &DeviceCode,
deadline: Duration,
) -> Result<Tokens, ExecError>
pub async fn device_poll( &self, code: &DeviceCode, deadline: Duration, ) -> Result<Tokens, ExecError>
Polls until the user approves (pollCodexDeviceToken), then exchanges the code.
Sourcepub async fn refresh_patch(
&self,
refresh_token: &str,
) -> Result<MetadataPatch, ExecError>
pub async fn refresh_patch( &self, refresh_token: &str, ) -> Result<MetadataPatch, ExecError>
The patch Go’s CodexExecutor.Refresh applies to credential metadata.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for CodexOAuth
impl !UnwindSafe for CodexOAuth
impl Freeze for CodexOAuth
impl Send for CodexOAuth
impl Sync for CodexOAuth
impl Unpin for CodexOAuth
impl UnsafeUnpin for CodexOAuth
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more