Skip to content

Rust API bindings for Google Sign-in

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

wyyerd/google-signin-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Sign-In for Rust

google-signin on crates.io google-signin on docs.rs

Rust API bindings for Google Sign-in.
See authenticating with a backend server.

Usage

Put this in your Cargo.toml:

[dependencies]
google-signin = "0.3.0"

And this in your crate root:

extern crate google_signin;

And then you can verify a google JSON web token

use google_signin;
let mut client = google_signin::Client::new();
client.audiences.push(YOUR_CLIENT_ID); // required
client.hosted_domains.push(YOUR_HOSTED_DOMAIN); // optional

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

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

Other Notes

The verify function currently uses the tokeninfo endpoint which handles most of the validation logic, but introduces some latency.

If you are expecting high volumes of sign-ins:

About

Rust API bindings for Google Sign-in

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages