#google #website #sdk

async-google-auth

Google Website Auth SDK for Rust

1 stable release

1.0.0 Feb 23, 2025

#755 in Authentication

Download history 134/week @ 2025-02-19 33/week @ 2025-02-26

167 downloads per month

MIT license

19KB
78 lines

Google Website Auth SDK for Rust

use dotenvy::dotenv;
use std::env;

use crate::Google;

fn main() {
    dotenv().ok();
    let appid = env::var("GOOGLE_CLIENT_ID").expect("GOOGLE_CLIENT_ID must be set");
    let app_secret =
        env::var("GOOGLE_CLIENT_SECRET").expect("GOOGLE_CLIENT_SECRET must be set");
    let callback_url =
        env::var("GOOGLE_CALLBACK_URL").expect("GOOGLE_CALLBACK_URL must be set");
    let google = Google::new(appid, app_secret, callback_url);

    let redirect_url = google.get_redirect_url();
    println!("Redirect URL: {}", redirect_url);

    let profile = google.get_userinfo("YOUR_AUTHORIZATION_CODE".to_string()).await.unwrap();
    println!("Profile: {:#?}", profile);
}

Dependencies

~7–19MB
~274K SLoC