id_token_parser 0.2.5

Parse and validate third party jwt token with jsonwebtoken
Documentation
use crate::util::deserialize_bool_or_string;

use serde::{Deserialize, Serialize};

/// Example from https://developers.google.com/identity/sign-in/web/backend-auth#calling-the-tokeninfo-endpoint
/// {
///   // These six fields are included in all Google ID Tokens.
///   "iss": "https://accounts.google.com",
///   "sub": "110169484474386276334",
///   "azp": "1008719970978-hb24n2dstb40o45d4feuo2ukqmcc6381.apps.googleusercontent.com",
///   "aud": "1008719970978-hb24n2dstb40o45d4feuo2ukqmcc6381.apps.googleusercontent.com",
///   "iat": "1433978353",
///   "exp": "1433981953",
///   
///   // These seven fields are only included when the user has granted the "profile" and
///   // "email" OAuth scopes to the application.
///   "email": "testuser@gmail.com",
///   "email_verified": "true",
///   "name" : "Test User",
///   "picture": "https://lh4.googleusercontent.com/-kYgzyAWpZzJ/ABCDEFGHI/AAAJKLMNOP/tIXL9Ir44LE/s99-c/photo.jpg",
///   "given_name": "Test",
///   "family_name": "User",
///   "locale": "en"
/// }
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GoogleTokenClaims {
  pub iss: String,
  pub sub: String,
  pub azp: String,
  pub aud: String,
  pub iat: u64,
  pub exp: u64,

  #[serde(default)]
  pub email: Option<String>,
  #[serde(default, deserialize_with = "deserialize_bool_or_string")]
  pub email_verified: Option<bool>,
  #[serde(default)]
  pub name: Option<String>,
  #[serde(default)]
  pub picture: Option<String>,
  #[serde(default)]
  pub given_name: Option<String>,
  #[serde(default)]
  pub family_name: Option<String>,
  #[serde(default)]
  pub locale: Option<String>,
}