ej_auth/
auth_body.rs

1//! Authentication response structures.
2//!
3//! Standard response format for authentication tokens.
4
5use serde::{Deserialize, Serialize};
6
7use super::CONNECTION_TOKEN_TYPE;
8
9/// Authentication response with access token.
10///
11/// Contains an access token and token type for HTTP authentication.
12///
13/// # JSON Format
14///
15/// ```json
16/// {
17///   "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
18///   "token_type": "Bearer"
19/// }
20/// ```
21#[derive(Debug, Deserialize, Serialize)]
22pub struct AuthBody {
23    /// The access token.
24    pub access_token: String,
25    /// The token type (always "Bearer").
26    pub token_type: String,
27}
28impl AuthBody {
29    /// Creates a new authentication response.
30    ///
31    /// # Arguments
32    ///
33    /// * `access_token` - The authentication token
34    ///
35    /// # Examples
36    ///
37    /// ```rust
38    /// use ej_auth::auth_body::AuthBody;
39    ///
40    /// let response = AuthBody::new("some_token".to_string());
41    /// assert_eq!(response.token_type, "Bearer");
42    /// ```
43    pub fn new(access_token: String) -> Self {
44        Self {
45            access_token,
46            token_type: String::from(CONNECTION_TOKEN_TYPE),
47        }
48    }
49}