azure_identity/device_code_flow/
device_code_responses.rs1use azure_core::auth::Secret;
2use serde::Deserialize;
3use std::fmt;
4
5#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
7pub struct DeviceCodeErrorResponse {
8 pub error: String,
10 pub error_description: String,
12 pub error_uri: String,
14}
15
16impl std::error::Error for DeviceCodeErrorResponse {}
17
18impl fmt::Display for DeviceCodeErrorResponse {
19 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
21 write!(f, "{}. {}", self.error, self.error_description)
22 }
23}
24
25#[derive(Debug, Clone, Deserialize)]
27pub struct DeviceCodeAuthorization {
28 pub token_type: String,
30 pub scope: String,
33 pub expires_in: u64,
35 access_token: Secret,
38 refresh_token: Option<Secret>,
41 id_token: Option<Secret>,
44}
45
46impl DeviceCodeAuthorization {
47 pub fn access_token(&self) -> &Secret {
49 &self.access_token
50 }
51 pub fn refresh_token(&self) -> Option<&Secret> {
53 self.refresh_token.as_ref()
54 }
55 pub fn id_token(&self) -> Option<&Secret> {
57 self.id_token.as_ref()
58 }
59}