Skip to main content

lichess_api/model/oauth/
mod.rs

1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4
5pub mod authorize;
6pub mod pending;
7pub mod pkce;
8pub mod revoke;
9pub mod test;
10pub mod token;
11
12pub use pending::PendingAuthorization;
13pub use pkce::Pkce;
14
15/// Maps each tested token to its details, or `None` if the token is invalid.
16pub type TestResults = HashMap<String, Option<Token>>;
17
18/// An access token obtained by exchanging an authorization code.
19#[derive(Clone, Debug, Deserialize, Serialize)]
20pub struct AccessToken {
21    pub token_type: String,
22    pub access_token: String,
23    /// Lifetime of the token in seconds.
24    pub expires_in: u64,
25}
26
27#[derive(Clone, Debug, Deserialize, Serialize)]
28#[serde(rename_all = "camelCase")]
29pub struct Token {
30    /// Comma separated
31    pub scopes: String,
32    pub user_id: String,
33    /// Unix timestamp in milliseconds, or `None` if the token never expires.
34    pub expires: Option<u64>,
35}