rusty_box/auth/
access_token.rs

1//! Structures for the access token response from the Box API.
2/*
3 * Box Platform API
4 *
5 * [Box Platform](https://box.dev) provides functionality to provide access to content stored within [Box](https://box.com). It provides endpoints for basic manipulation of files and folders, management of users within an enterprise, as well as more complex topics such as legal holds and retention policies.
6 *
7 * The version of the OpenAPI document: 2.0.0
8 * Contact: devrel@box.com
9 * Generated by: https://openapi-generator.tech
10 */
11
12use crate::rest_api::files::models::file_scope::FileScope;
13
14/// AccessToken : A token that can be used to make authenticated API calls.
15
16#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
17pub struct AccessToken {
18    /// The requested access token.
19    #[serde(rename = "access_token", skip_serializing_if = "Option::is_none")]
20    pub access_token: Option<String>,
21    /// The time in seconds in seconds by which this token will expire.
22    #[serde(rename = "expires_in", skip_serializing_if = "Option::is_none")]
23    pub expires_in: Option<i64>,
24    /// The type of access token returned.
25    #[serde(rename = "token_type", skip_serializing_if = "Option::is_none")]
26    pub token_type: Option<TokenType>,
27    /// The permissions that this access token permits, providing a list of resources (files, folders, etc) and the scopes permitted for each of those resources.
28    #[serde(rename = "restricted_to", skip_serializing_if = "Option::is_none")]
29    pub restricted_to: Option<Vec<FileScope>>,
30    /// The refresh token for this access token, which can be used to request a new access token when the current one expires.
31    #[serde(rename = "refresh_token", skip_serializing_if = "Option::is_none")]
32    pub refresh_token: Option<String>,
33    /// The type of downscoped access token returned. This is only returned if an access token has been downscoped.
34    #[serde(rename = "issued_token_type", skip_serializing_if = "Option::is_none")]
35    pub issued_token_type: Option<IssuedTokenType>,
36}
37
38impl AccessToken {
39    /// A token that can be used to make authenticated API calls.
40    pub fn new() -> AccessToken {
41        AccessToken {
42            access_token: None,
43            expires_in: None,
44            token_type: None,
45            restricted_to: None,
46            refresh_token: None,
47            issued_token_type: None,
48        }
49    }
50}
51
52/// The type of access token returned.
53#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
54pub enum TokenType {
55    #[serde(rename = "bearer")]
56    Bearer,
57}
58
59impl Default for TokenType {
60    fn default() -> TokenType {
61        Self::Bearer
62    }
63}
64/// The type of downscoped access token returned. This is only returned if an access token has been downscoped.
65#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
66pub enum IssuedTokenType {
67    #[serde(rename = "urn:ietf:params:oauth:token-type:access_token")]
68    UrnColonIetfColonParamsColonOauthColonTokenTypeColonAccessToken,
69}
70
71impl Default for IssuedTokenType {
72    fn default() -> IssuedTokenType {
73        Self::UrnColonIetfColonParamsColonOauthColonTokenTypeColonAccessToken
74    }
75}