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 在 身份验证 中排名
每月下载 199 次
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