auth0-integration 0.6.1

Auth0 client library for M2M token retrieval and JWT validation (RS256)
Documentation
use std::fmt;

use serde::Deserialize;
use serde_json::Value;

use super::access_token::AccessToken;

#[derive(Debug, Deserialize)]
pub struct AccessTokenResponse {
    pub access_token: AccessToken,
    pub token_type: String,
    pub expires_in: u64,
}

impl AccessTokenResponse {
    pub fn to_json(&self) -> Value {
        serde_json::json!({
            "access_token": self.access_token.token,
            "token_type": self.token_type,
            "expires_in": self.expires_in,
        })
    }
}

impl fmt::Display for AccessTokenResponse {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.access_token.token)
    }
}