pub struct TokenSet {
pub access_token: String,
pub id_token: Option<String>,
pub refresh_token: String,
pub expires_at: u64,
pub api_key: Option<String>,
}Expand description
OAuth token set containing access token, refresh token, and expiration info
Fields§
§access_token: StringThe access token used to authenticate API requests
id_token: Option<String>The ID token returned by OpenAI (used for API key exchange)
refresh_token: StringThe refresh token used to obtain new access tokens
expires_at: u64Unix timestamp (seconds) when the access token expires
api_key: Option<String>OpenAI API key derived from token exchange
Implementations§
Source§impl TokenSet
impl TokenSet
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if the token is expired or will expire soon (within 5 minutes)
This includes a 5-minute buffer to prevent race conditions where a token expires between checking and using it.
Sourcepub fn expires_in(&self) -> Duration
pub fn expires_in(&self) -> Duration
Get the duration until the token expires
Returns Duration::ZERO if the token is already expired.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TokenSet
impl<'de> Deserialize<'de> for TokenSet
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for TokenSet
impl RefUnwindSafe for TokenSet
impl Send for TokenSet
impl Sync for TokenSet
impl Unpin for TokenSet
impl UnwindSafe for TokenSet
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
Mutably borrows from an owned value. Read more