azure_identity_helpers/device_code/
device_code_responses.rs1use azure_core::credentials::Secret;
5use serde::Deserialize;
6use std::fmt;
7
8#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
10pub struct DeviceCodeErrorResponse {
11 pub error: String,
13 pub error_description: String,
15 pub error_uri: String,
17}
18
19impl std::error::Error for DeviceCodeErrorResponse {}
20
21impl fmt::Display for DeviceCodeErrorResponse {
22 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
24 write!(f, "{}. {}", self.error, self.error_description)
25 }
26}
27
28#[derive(Debug, Clone, Deserialize)]
30pub struct DeviceCodeAuthorization {
31 pub token_type: String,
33 pub scope: String,
36 pub expires_in: u64,
38 access_token: Secret,
41 refresh_token: Option<Secret>,
44 id_token: Option<Secret>,
47}
48
49impl DeviceCodeAuthorization {
50 #[must_use]
52 pub fn access_token(&self) -> &Secret {
53 &self.access_token
54 }
55 #[must_use]
57 pub fn refresh_token(&self) -> Option<&Secret> {
58 self.refresh_token.as_ref()
59 }
60 #[must_use]
62 pub fn id_token(&self) -> Option<&Secret> {
63 self.id_token.as_ref()
64 }
65}