pub struct TokenResponse {
pub access_token: Secret<String>,
pub token_type: String,
pub expires_in: Option<u64>,
pub refresh_token: Option<Secret<String>>,
pub scope: Option<String>,
pub issued_at: OffsetDateTime,
}
Expand description
Response from the token endpoint
Fields§
§access_token: Secret<String>
The access token
token_type: String
The token type (usually “Bearer”)
expires_in: Option<u64>
How long the access token is valid for in seconds
refresh_token: Option<Secret<String>>
The refresh token (if available)
scope: Option<String>
The scopes granted
issued_at: OffsetDateTime
When this token was issued (set by the library)
Implementations§
Source§impl TokenResponse
impl TokenResponse
Sourcepub fn access_token(&self) -> &str
pub fn access_token(&self) -> &str
Get the access token (secret)
Sourcepub fn refresh_token(&self) -> Option<&str>
pub fn refresh_token(&self) -> Option<&str>
Get the refresh token (secret) if available
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if the token is expired
Sourcepub fn expires_at(&self) -> Option<OffsetDateTime>
pub fn expires_at(&self) -> Option<OffsetDateTime>
Get the expiration time
Sourcepub fn remaining_lifetime(&self) -> Option<Duration>
pub fn remaining_lifetime(&self) -> Option<Duration>
Get the remaining lifetime of the token
Sourcepub fn expires_within(&self, duration: Duration) -> bool
pub fn expires_within(&self, duration: Duration) -> bool
Check if the token will expire within the given duration
Trait Implementations§
Source§impl Clone for TokenResponse
impl Clone for TokenResponse
Source§fn clone(&self) -> TokenResponse
fn clone(&self) -> TokenResponse
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for TokenResponse
impl Debug for TokenResponse
Source§impl<'de> Deserialize<'de> for TokenResponse
impl<'de> Deserialize<'de> for TokenResponse
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 TokenResponse
impl RefUnwindSafe for TokenResponse
impl Send for TokenResponse
impl Sync for TokenResponse
impl Unpin for TokenResponse
impl UnwindSafe for TokenResponse
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