google_oauth/
output.rs

1use serde::{Serialize, Deserialize};
2#[cfg(feature = "wasm")]
3use wasm_bindgen::prelude::*;
4
5/// `GooglePayload` is the user data from google.
6///
7/// see https://developers.google.com/identity/openid-connect/openid-connect for more info.
8#[derive(Debug, Clone, Serialize, Deserialize)]
9#[non_exhaustive]
10#[cfg_attr(feature = "wasm", wasm_bindgen(getter_with_clone))]
11pub struct GooglePayload {
12    // These fields are marked `always`.
13    pub aud: String,
14    pub exp: u64,
15    pub iat: u64,
16    pub iss: String,
17    pub sub: String,
18
19    // These fields are optional.
20    pub at_hash: Option<String>,
21    pub azp: Option<String>,
22    pub email: Option<String>,
23    pub email_verified: Option<bool>,
24    pub family_name: Option<String>,
25    pub given_name: Option<String>,
26    pub hd: Option<String>,
27    pub locale: Option<String>,
28    pub name: Option<String>,
29    pub nonce: Option<String>,
30    pub picture: Option<String>,
31
32    // These fields not list in document, but may exist
33    pub nbf: Option<u64>,
34    pub jti: Option<String>,
35}
36
37/// `GoogleAccessTokenPayload` is the user data when using access token
38///
39/// reference: https://stackoverflow.com/questions/16501895/how-do-i-get-user-profile-using-google-access-token
40///
41/// reference: https://gist.github.com/evanj/e415d808dbb6c2a0bd866cd9d17ef5aa
42#[derive(Debug, Clone, Serialize, Deserialize)]
43#[non_exhaustive]
44#[cfg_attr(feature = "wasm", wasm_bindgen(getter_with_clone))]
45pub struct GoogleAccessTokenPayload {
46    pub sub: String,
47    pub picture: Option<String>,
48    pub name: Option<String>,
49    pub locale: Option<String>,
50    pub given_name: Option<String>,
51    pub email: Option<String>,
52    pub email_verified: Option<bool>,
53}