Skip to main content

wiremux_auth/
exchange.rs

1//! Shared OAuth token-exchange response (PKCE and device flow).
2
3use serde::Deserialize;
4
5/// Token response from an authorization-code or device-code exchange.
6#[derive(Clone, Deserialize)]
7pub struct TokenExchangeResponse {
8    /// Access token.
9    pub access_token: String,
10    /// Refresh token, when issued.
11    #[serde(default)]
12    pub refresh_token: Option<String>,
13    /// Lifetime in seconds.
14    #[serde(default)]
15    pub expires_in: Option<u64>,
16    /// Token type (`Bearer`).
17    #[serde(default)]
18    pub token_type: Option<String>,
19    /// Granted scope string.
20    #[serde(default)]
21    pub scope: Option<String>,
22}
23
24impl std::fmt::Debug for TokenExchangeResponse {
25    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26        f.debug_struct("TokenExchangeResponse")
27            .field("access_token", &"[REDACTED]")
28            .field(
29                "refresh_token",
30                &self.refresh_token.as_ref().map(|_| "[REDACTED]"),
31            )
32            .field("expires_in", &self.expires_in)
33            .field("token_type", &self.token_type)
34            .field("scope", &self.scope)
35            .finish()
36    }
37}