Skip to content

struct

Token

pub struct Token {
    pub access_token: String,
    pub expires_at: f64,
}

An access token and when it expires (seconds on your clock).

Fields

access_token

pub access_token: String

The token to send as Authorization: Bearer ….

expires_at

pub expires_at: f64

When it expires, in seconds.

Methods

parse

pub fn parse(res: &Response, now: f64) -> Result<Token, Error>

Parse a token reply received at now (seconds). Expiry is brought forward a minute, and capped at 15 minutes (Halaxy's documented lifetime, whatever expires_in says).

is_fresh

pub fn is_fresh(&self, now: f64) -> bool

Whether the token is still good at now (seconds since the epoch).

Trait implementations