Struct oxide_auth::primitives::issuer::IssuedToken[][src]

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: String

The 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: TokenType

The type of the token.

Implementations

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))
    }
    // …
}

Determine if the access token can be refreshed.

This returns false if refresh is None and true otherwise.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.