mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2026-01-06 19:29:39 +01:00
fix(flows): save Token properly
The installed flow didn't explicitly set the retrieved token absolute, which would cause failures down the road.
This commit is contained in:
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -1,6 +1,6 @@
|
||||
[root]
|
||||
name = "yup-oauth2"
|
||||
version = "0.5.6"
|
||||
version = "0.6.0"
|
||||
dependencies = [
|
||||
"chrono 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -15,7 +15,7 @@ dependencies = [
|
||||
"serde_macros 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syntex 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"yup-hyper-mock 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"yup-hyper-mock 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -505,7 +505,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "yup-hyper-mock"
|
||||
version = "1.3.2"
|
||||
version = "1.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"hyper 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
||||
@@ -117,7 +117,7 @@ impl Token {
|
||||
|
||||
/// Returns a DateTime object representing our expiry date.
|
||||
pub fn expiry_date(&self) -> DateTime<UTC> {
|
||||
UTC.timestamp(self.expires_in_timestamp.unwrap(), 0)
|
||||
UTC.timestamp(self.expires_in_timestamp.expect("Tokens without an absolute expiry are invalid"), 0)
|
||||
}
|
||||
|
||||
/// Adjust our stored expiry format to be absolute, using the current time.
|
||||
|
||||
@@ -139,14 +139,15 @@ impl<C> InstalledFlow<C> where C: BorrowMut<hyper::Client>
|
||||
|
||||
// Successful response
|
||||
if tokens.access_token.is_some() {
|
||||
let token = Token {
|
||||
let mut token = Token {
|
||||
access_token: tokens.access_token.unwrap(),
|
||||
refresh_token: tokens.refresh_token.unwrap(),
|
||||
token_type: tokens.token_type.unwrap(),
|
||||
expires_in: tokens.expires_in,
|
||||
expires_in_timestamp: None,
|
||||
};
|
||||
|
||||
|
||||
token.set_expiry_absolute();
|
||||
Result::Ok(token)
|
||||
} else {
|
||||
let err = io::Error::new(io::ErrorKind::Other,
|
||||
|
||||
Reference in New Issue
Block a user