#google-api #sign-in #wasm

google-signin-client

Client API for Google sign in client

4 releases

0.2.0 May 20, 2024
0.1.3 Jan 18, 2024
0.1.2 Dec 14, 2023
0.1.1 Dec 14, 2023

#954 in Authentication

Download history 1/week @ 2025-05-04 7/week @ 2025-05-11

199 downloads per month

MIT license

27KB
528 lines

Google Signin

It is a shallow wrapper over some features of the google javascript sign in library

Usage

Initialization

Include the javascript library from google into your html file:


<head>
    <script src="https://accounts.google.com/gsi/client"></script>
</head>

Now call the initialization on the API:

let mut configuration = IdConfiguration::new(client_id);
configuration.set_callback(Box::new( move | response| {
    let jwt_token = response.credential();
    // handle JWT Token
}));
initialize(configuration);

Call login procedure

Initiating the login prompt by calling the API:

spawn_local( async move {
    let result = prompt_async().await;
    if result != PromptResult::Dismissed(DismissedReason::CredentialReturned) {
        // handle error condition (in case of success, the callback configured before is called)
    }
});

Dependencies

~7–28MB
~467K SLoC