Skip to content

Commit

Permalink
fix(flows): save Token properly
Browse files Browse the repository at this point in the history
The installed flow didn't explicitly set the retrieved token
absolute, which would cause failures down the road.
  • Loading branch information
Byron committed May 20, 2016
1 parent a9d0b06 commit 57a3151
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions src/installed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 57a3151

Please sign in to comment.