pub struct IssuedToken {
pub token: String,
pub refresh: Option<String>,
pub until: DateTime<Utc>,
pub token_type: TokenType,
}Expand description
Token parameters returned to a client.
Fields§
§token: StringThe bearer token
refresh: Option<String>The refresh token, if any.
until: DateTime<Utc>Expiration timestamp (Utc).
Technically, a time to live is expected in the response but this will be transformed later. In a direct backend access situation, this enables high precision timestamps.
token_type: TokenTypeThe type of the token.
Implementations§
Source§impl IssuedToken
impl IssuedToken
Sourcepub fn without_refresh(token: String, until: DateTime<Utc>) -> Self
pub fn without_refresh(token: String, until: DateTime<Utc>) -> Self
Construct a token that can not be refreshed.
This is essential for issuers that can not revoke their tokens. Since refresh tokens are both long-lived and more powerful than their access token counterparts, it is more dangerous to have an unrevokable refresh token.
This is only a shorthand for initializing the IssuedToken with None for refresh.
use oxide_auth::primitives::grant::Grant;
use oxide_auth::primitives::issuer::{Issuer, IssuedToken};
struct MyIssuer;
impl MyIssuer {
fn access_token(&mut self, grant: &Grant) -> String {
// .. your implementation
}
}
impl Issuer for MyIssuer {
fn issue(&mut self, mut grant: Grant) -> Result<IssuedToken, ()> {
let token = self.access_token(&grant);
Ok(IssuedToken::without_refresh(token, grant.until))
}
// …
}Sourcepub fn refreshable(&self) -> bool
pub fn refreshable(&self) -> bool
Determine if the access token can be refreshed.
This returns false if refresh is None and true otherwise.
Sourcepub fn convert_bearer_token(self, pre_grant: PreGrant) -> BearerToken
pub fn convert_bearer_token(self, pre_grant: PreGrant) -> BearerToken
Convert this issued token to an access bearer token given a grant
Trait Implementations§
Source§impl Clone for IssuedToken
impl Clone for IssuedToken
Source§fn clone(&self) -> IssuedToken
fn clone(&self) -> IssuedToken
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more