pub enum Credential {
Oauth(OAuthCredential),
Apikey {
key: String,
},
}Variants§
Oauth(OAuthCredential)
OAuth credential with access + refresh tokens and an expiry. Used by Anthropic (claude.ai) and OpenAI (chatgpt.com) accounts.
Apikey
Static API key — no expiry, no refresh. Used by Groq, Mistral, OpenRouter, Gemini, Ollama Cloud, etc.
Implementations§
Source§impl Credential
impl Credential
Sourcepub fn bearer_token(&self) -> &str
pub fn bearer_token(&self) -> &str
The bearer token to send in Authorization: Bearer <token>.
For OAuth accounts: prefers id_token over access_token when
present (required by chatgpt.com / Codex). Falls back to
access_token for standard Anthropic OAuth.
For API-key accounts: returns the raw key directly.
Sourcepub fn access_token(&self) -> &str
pub fn access_token(&self) -> &str
The raw access_token string.
Used when you need the access_token specifically (e.g. token-rotation comparison in the 401 handler, Anthropic auth headers).
For API-key accounts returns the key (same as bearer_token).
Sourcepub fn needs_refresh(&self) -> bool
pub fn needs_refresh(&self) -> bool
True if the credential should be refreshed before use. Always false for API-key credentials.
Sourcepub fn has_refresh_token(&self) -> bool
pub fn has_refresh_token(&self) -> bool
True when a refresh_token is available to attempt recovery. Always false for API-key credentials.
Sourcepub fn as_oauth(&self) -> Option<&OAuthCredential>
pub fn as_oauth(&self) -> Option<&OAuthCredential>
Borrow the inner OAuthCredential, if this is an OAuth credential.
Sourcepub fn as_oauth_mut(&mut self) -> Option<&mut OAuthCredential>
pub fn as_oauth_mut(&mut self) -> Option<&mut OAuthCredential>
Mutably borrow the inner OAuthCredential.
Sourcepub fn masked_display(&self) -> String
pub fn masked_display(&self) -> String
Display string for status/monitor output. Shows email for OAuth accounts, masked key for API-key accounts.
Trait Implementations§
Source§impl Clone for Credential
impl Clone for Credential
Source§fn clone(&self) -> Credential
fn clone(&self) -> Credential
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Credential
impl Debug for Credential
Source§impl<'de> Deserialize<'de> for Credential
impl<'de> Deserialize<'de> for Credential
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<OAuthCredential> for Credential
impl From<OAuthCredential> for Credential
Source§fn from(c: OAuthCredential) -> Self
fn from(c: OAuthCredential) -> Self
Auto Trait Implementations§
impl Freeze for Credential
impl RefUnwindSafe for Credential
impl Send for Credential
impl Sync for Credential
impl Unpin for Credential
impl UnsafeUnpin for Credential
impl UnwindSafe for Credential
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
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