Crate google_signin [] [src]

Google Sign-In

This crate provides an API to verify Google's OAuth client id tokens for use with Google is an authentication provider.

Typically these tokens are generated by a web application using the Google Platform Library.

Getting Started

Create a new client and configure it with your client id(s).

extern crate google_signin;

let mut client = google_signin::Client::new();
client.audiences.push("".to_string()); // required
client.hosted_domains.push("YOUR_HOSTED_DOMAIN.tld".to_string()); // optional

When you get an id token (typically in an HTTP request handler), you should verify it using the client's verify method:

struct GoogleLogin {
    token: String,

// Recommended: Let the crate handle everything for you
let id_info = client.verify(&request.token).expect("Expected token to be valid");
println!("Success! Signed-in as {}", id_info.sub);

// Alternative: Inspect the ID before verifying it
let id_info = client.get_slow_unverified(&request.token).expect("Expected token to exist");
let ok = id_info.verify(&client).is_ok();
println!("Ok: {}, Info: {:?}", ok, id_info);





A network or validation error