pub struct Token {
pub expires_in: u64,
pub created_at: DateTime<Utc>,
pub expires_at: DateTime<Utc>,
/* private fields */
}
Expand description
An OAuth2 token.
Fields§
§expires_in: u64
How long until the current token expires, in seconds.
created_at: DateTime<Utc>
The UTC date and time when the token was created.
expires_at: DateTime<Utc>
The UTC date and time when the token will expire.
Implementations§
Source§impl Token
impl Token
Sourcepub fn new(
access_token: impl Into<String>,
refresh_token: Option<&str>,
created_at: DateTime<Utc>,
expires_in: u64,
scopes: Option<Scopes>,
) -> Self
pub fn new( access_token: impl Into<String>, refresh_token: Option<&str>, created_at: DateTime<Utc>, expires_in: u64, scopes: Option<Scopes>, ) -> Self
Create a new token, to be used with one of the from_access_token
methods.
Sourcepub fn refresh_secret(&self) -> Option<&str>
pub fn refresh_secret(&self) -> Option<&str>
Get the current refresh token. Some auth flows may not provide a refresh token,
in which case it will return None
.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Returns true
if the access token has expired.
Sourcepub fn is_refreshable(&self) -> bool
pub fn is_refreshable(&self) -> bool
Returns true
if a refresh token is present.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Token
impl<'de> Deserialize<'de> for Token
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
Source§impl TokenResponse<BasicTokenType> for Token
impl TokenResponse<BasicTokenType> for Token
Source§fn access_token(&self) -> &AccessToken
fn access_token(&self) -> &AccessToken
REQUIRED. The access token issued by the authorization server.
Source§fn token_type(&self) -> &BasicTokenType
fn token_type(&self) -> &BasicTokenType
REQUIRED. The type of the token issued as described in
Section 7.1.
Value is case insensitive and deserialized to the generic
TokenType
parameter.Source§fn expires_in(&self) -> Option<Duration>
fn expires_in(&self) -> Option<Duration>
RECOMMENDED. The lifetime in seconds of the access token. For example, the value 3600
denotes that the access token will expire in one hour from the time the response was
generated. If omitted, the authorization server SHOULD provide the expiration time via
other means or document the default value.
Source§fn refresh_token(&self) -> Option<&RefreshToken>
fn refresh_token(&self) -> Option<&RefreshToken>
OPTIONAL. The refresh token, which can be used to obtain new access tokens using the same
authorization grant as described in
Section 6.
Source§fn scopes(&self) -> Option<&Vec<Scope>>
fn scopes(&self) -> Option<&Vec<Scope>>
OPTIONAL, if identical to the scope requested by the client; otherwise, REQUIRED. The
scope of the access token as described by
Section 3.3. If included in the response,
this space-delimited field is parsed into a
Vec
of individual scopes. If omitted from
the response, this field is None
.Auto Trait Implementations§
impl Freeze for Token
impl RefUnwindSafe for Token
impl Send for Token
impl Sync for Token
impl Unpin for Token
impl UnwindSafe for Token
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