myc_http_tools/providers/google/
models.rs1use serde::{Deserialize, Deserializer, Serialize};
2
3#[derive(Debug, Serialize, Deserialize)]
4pub(super) struct TokenClaims {
5 pub sub: String,
6 pub iat: usize,
7 pub exp: usize,
8 pub iss: String,
9 pub id: String,
10 pub email: String,
11 pub verified_email: bool,
12 pub name: String,
13 pub given_name: String,
14 pub family_name: String,
15 pub picture: String,
16 pub locale: String,
17}
18
19#[derive(Debug, Deserialize)]
20pub struct QueryCode {
21 pub code: String,
22 pub state: String,
23}
24
25#[derive(Deserialize, Debug)]
26pub(super) struct OAuthResponse {
27 pub access_token: String,
28 pub id_token: String,
29}
30
31#[derive(Deserialize, Debug)]
32pub(super) struct GoogleUserResult {
33 pub id: String,
34 pub email: String,
35 pub verified_email: bool,
36 pub name: String,
37 pub given_name: String,
38 pub family_name: String,
39 pub picture: String,
40 pub locale: String,
41}
42
43#[derive(Deserialize, Debug)]
44pub(super) struct GoogleDecode {
45 pub email: String,
46
47 #[serde(deserialize_with = "bool_from_string")]
48 pub email_verified: bool,
49}
50
51fn bool_from_string<'de, D>(deserializer: D) -> Result<bool, D::Error>
52where
53 D: Deserializer<'de>,
54{
55 let s = String::deserialize(deserializer)?;
56 match s.as_str() {
57 "true" => Ok(true),
58 "false" => Ok(false),
59 _ => Err(serde::de::Error::custom("invalid value")),
60 }
61}