[][src]Struct tame_oauth::Token

pub struct Token {
    pub access_token: String,
    pub refresh_token: String,
    pub token_type: String,
    pub expires_in: Option<i64>,
    pub expires_in_timestamp: Option<i64>,
}

Represents a token as returned by OAuth2 servers.

It is produced by all authentication flows. It authenticates certain operations, and must be refreshed once it reached its expiry date.

The type is tuned to be suitable for direct de-serialization from server replies, as well as for serialization for later reuse. This is the reason for the two fields dealing with expiry - once in relative in and once in absolute terms.

Utility methods make common queries easier, see expired().

Fields

access_token: String

used when authenticating calls to oauth2 enabled services.

refresh_token: String

used to refresh an expired access_token.

token_type: String

The token type as string - usually 'Bearer'.

expires_in: Option<i64>

access_token will expire after this amount of time. Prefer using expiry_date()

expires_in_timestamp: Option<i64>

timestamp is seconds since epoch indicating when the token will expire in absolute terms. use expiry_date() to convert to DateTime.

Implementations

impl Token[src]

pub fn has_expired(&self) -> bool[src]

Returns true if we are expired.

pub fn expiry_date(&self) -> DateTime<Utc>[src]

Returns a DateTime object representing our expiry date.

Trait Implementations

impl Clone for Token[src]

impl Debug for Token[src]

impl<'de> Deserialize<'de> for Token[src]

impl PartialEq<Token> for Token[src]

impl StructuralPartialEq for Token[src]

impl TryInto<HeaderValue> for Token[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.