Crates.io | google-jwt-verify |
lib.rs | google-jwt-verify |
version | 0.3.0 |
source | src |
created_at | 2018-05-18 00:08:31.763762 |
updated_at | 2020-12-04 02:39:34.144831 |
description | A client to verify Google JSON web tokens |
homepage | |
repository | https://github.com/fuchsnj/google-jwt-verify |
max_upload_size | |
id | 65944 |
size | 25,063 |
This can be used to verify Google JWT tokens. Google's public keys are automatically fetched and cached according to the returned Cache-Control headers. Most requests to verify a token through this library will not wait for an HTTP request
For more info: https://developers.google.com/identity/sign-in/web/backend-auth
//If you don't have a client id, get one from here: https://console.developers.google.com/
let client_id = "37772117408-qjqo9hca513pdcunumt7gk08ii6te8is.apps.googleusercontent.com";
let token = "...";// Obtain a signed token from Google
let client = Client::new(&client_id);
let id_token = client.verify_id_token(&token)?;
//use the token to obtain information about the verified user
let user_id = id_token.get_claims().get_subject();
let email = id_token.get_payload().get_email();
let name = id_token.get_payload().get_name();