#google #sign-in #wasm #api-client

google-signin-client

Google 登录客户端的客户端 API

4 个版本

0.2.0 2024年5月20日
0.1.3 2024年1月18日
0.1.2 2023年12月14日
0.1.1 2023年12月14日

526身份验证 中排名

Download history · Rust 包仓库 18/week @ 2024-04-04 · Rust 包仓库 165/week @ 2024-05-16 · Rust 包仓库 20/week @ 2024-05-23 · Rust 包仓库

每月下载 199

MIT 许可证

27KB
528

Google Signin

它是 Google JavaScript 登录库的一些功能的浅层封装[链接]

用法

初始化

将 Google 的 JavaScript 库包含到您的 html 文件中


<head>
    <script src="https://#/gsi/client"></script>
</head>

现在在 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);

调用登录过程

通过调用 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)
    }
});

依赖项

~6.5–8.5MB
~169K SLoC