Rust API bindings for Google Sign-in.
See authenticating with a backend server.
Put this in your Cargo.toml:
toml
[dependencies]
google-signin = "0.3.0"
And this in your crate root:
rust
extern crate google_signin;
And then you can verify a google JSON web token
```rust use googlesignin; let mut client = googlesignin::Client::new(); client.audiences.push(YOURCLIENTID); // required client.hosteddomains.push(YOURHOSTED_DOMAIN); // optional
// Let the crate handle everything for you let idinfo = client.verify(&data.token).expect("Expected token to be valid"); println!("Success! Signed-in as {}", idinfo.sub);
// Inspect the ID before verifying it let idinfo = client.getslowunverified(&data.token).expect("Expected token to exist"); let ok = idinfo.verify(&client).isok(); println!("Ok: {}, Info: {:?}", ok, idinfo); ```
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: * Add a reaction to the Handle Certificate and Cache-Control auth flow issue so we know how many people need it. * OR, Submit a Pull Request for the issue to help out.