pub struct TokenSet {
pub access_token: Secret,
pub refresh_token: Option<Secret>,
pub token_type: String,
pub expires_at: Option<OffsetDateTime>,
pub scopes: Vec<String>,
}Expand description
The credentials of one authenticated account.
Fields§
§access_token: Secret§refresh_token: Option<Secret>Absent when the provider issues no refresh token — the user then has to re-authenticate once the access token expires.
token_type: String§expires_at: Option<OffsetDateTime>Absent when the provider does not say; such tokens are treated as long-lived.
scopes: Vec<String>Scopes the provider actually granted, which can be fewer than requested.
Implementations§
Source§impl TokenSet
impl TokenSet
Sourcepub fn expires_within(&self, clock: &dyn Clock, skew: Duration) -> bool
pub fn expires_within(&self, clock: &dyn Clock, skew: Duration) -> bool
Whether the access token is expired, or will be within skew.
The skew matters: a token that is valid for another two seconds when checked will be rejected by the time the request arrives.
pub fn can_refresh(&self) -> bool
Sourcepub fn personal_access_token(
token: impl Into<String>,
scopes: Vec<String>,
) -> Self
pub fn personal_access_token( token: impl Into<String>, scopes: Vec<String>, ) -> Self
Credentials built from a token the user pasted in (B7/C1).
A personal access token has neither a refresh token nor a stated expiry: it is treated as long-lived until the service rejects it, at which point the account is marked expired and the user pastes a new one. No OAuth flow is involved.