Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fields for refresh token and expiry timestamps #477

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ pub struct OAuth {
pub access_token: SecretString,
pub token_type: String,
pub scope: Vec<String>,
pub expires_in: Option<usize>,
pub refresh_token: Option<SecretString>,
pub refresh_token_expires_in: Option<usize>,
}

/// The wire format of the OAuth struct.
Expand All @@ -108,6 +111,9 @@ struct OAuthWire {
access_token: String,
token_type: String,
scope: String,
expires_in: Option<usize>,
refresh_token: Option<String>,
refresh_token_expires_in: Option<usize>,
Comment on lines +114 to +116
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The size of expires_in and refresh_token_expires_in are currently fixed at 28800 and 15811200, respectively, so we could size down these fields to be Option<u16> and Option<u32>. I just copied the precedent for the Claims struct here

}

impl From<OAuthWire> for OAuth {
Expand All @@ -116,6 +122,9 @@ impl From<OAuthWire> for OAuth {
access_token: SecretString::from(value.access_token),
token_type: value.token_type,
scope: value.scope.split(',').map(ToString::to_string).collect(),
expires_in: value.expires_in,
refresh_token: value.refresh_token.map(|t| SecretString::from(t)),
refresh_token_expires_in: value.refresh_token_expires_in,
}
}
}
Expand Down