use azure_core::auth::Secret;
use serde::Deserialize;
use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
pub struct DeviceCodeErrorResponse {
pub error: String,
pub error_description: String,
pub error_uri: String,
}
impl std::error::Error for DeviceCodeErrorResponse {}
impl fmt::Display for DeviceCodeErrorResponse {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}. {}", self.error, self.error_description)
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct DeviceCodeAuthorization {
pub token_type: String,
pub scope: String,
pub expires_in: u64,
access_token: Secret,
refresh_token: Option<Secret>,
id_token: Option<Secret>,
}
impl DeviceCodeAuthorization {
pub fn access_token(&self) -> &Secret {
&self.access_token
}
pub fn refresh_token(&self) -> Option<&Secret> {
self.refresh_token.as_ref()
}
pub fn id_token(&self) -> Option<&Secret> {
self.id_token.as_ref()
}
}