2015-11-28 18:09:43 +00:00
|
|
|
use chrono::{DateTime, UTC};
|
|
|
|
|
|
|
|
/// OAuth 2.0 access token.
|
2015-11-28 20:20:51 +00:00
|
|
|
#[derive(Debug)]
|
2015-11-28 18:09:43 +00:00
|
|
|
pub struct Token {
|
|
|
|
pub access_token: String,
|
|
|
|
pub token_type: String,
|
|
|
|
pub expires: Option<DateTime<UTC>>,
|
|
|
|
pub refresh_token: Option<String>,
|
|
|
|
pub scope: Option<String>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Token {
|
|
|
|
/// Returns true if token is expired.
|
|
|
|
pub fn expired(&self) -> bool {
|
|
|
|
self.expires.map_or(false, |dt| dt < UTC::now())
|
|
|
|
}
|
|
|
|
}
|