Skip to main content

auth0_integration/models/access_token/
access_token_response.rs

1use std::fmt;
2
3use serde::Deserialize;
4use serde_json::Value;
5
6use super::access_token::AccessToken;
7
8#[derive(Debug, Deserialize)]
9pub struct AccessTokenResponse {
10    pub access_token: AccessToken,
11    pub token_type: String,
12    pub expires_in: u64,
13}
14
15impl AccessTokenResponse {
16    pub fn to_json(&self) -> Value {
17        serde_json::json!({
18            "access_token": self.access_token.token,
19            "token_type": self.token_type,
20            "expires_in": self.expires_in,
21        })
22    }
23}
24
25impl fmt::Display for AccessTokenResponse {
26    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27        write!(f, "{}", self.access_token.token)
28    }
29}