pub struct TokenResponse {
pub access_token: String,
pub refresh_token: Option<String>,
pub expires_in: Option<u64>,
pub token_type: Option<String>,
}Expand description
Response from the OAuth token endpoint.
This is the standard OAuth 2.0 token response format. The expires_in
field is seconds from now, which must be converted to an absolute
expires_at timestamp for storage.
Fields§
§access_token: StringThe access token issued by the authorization server.
refresh_token: Option<String>The refresh token (may not always be present, but required for stoat).
expires_in: Option<u64>The lifetime of the access token in seconds.
token_type: Option<String>The token type (typically “Bearer”).
Implementations§
Source§impl TokenResponse
impl TokenResponse
Sourcepub fn into_stored_token(
self,
now_unix: u64,
) -> Result<StoredToken, MissingRefreshToken>
pub fn into_stored_token( self, now_unix: u64, ) -> Result<StoredToken, MissingRefreshToken>
Convert to a StoredToken using the given current time.
now_unix is the current Unix timestamp in seconds. If expires_in
is not present, the token is assumed to expire in 3600 seconds (1 hour).
§Errors
Returns an error if refresh_token is None, since stoat requires
a refresh token for automatic token renewal.
Sourcepub fn into_refreshed_token(
self,
fallback_refresh_token: &str,
now_unix: u64,
) -> StoredToken
pub fn into_refreshed_token( self, fallback_refresh_token: &str, now_unix: u64, ) -> StoredToken
Convert a refresh response to a StoredToken, using the existing
refresh token as a fallback.
During a token refresh, the authorization server may or may not issue
a new refresh token. If the response does not include one, the
existing fallback_refresh_token is preserved.
now_unix is the current Unix timestamp in seconds. If expires_in
is not present, the token is assumed to expire in 3600 seconds (1 hour).
Trait Implementations§
Source§impl Clone for TokenResponse
impl Clone for TokenResponse
Source§fn clone(&self) -> TokenResponse
fn clone(&self) -> TokenResponse
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more