Crates.io | dioxus-oauth |
lib.rs | dioxus-oauth |
version | |
source | src |
created_at | 2024-11-12 00:02:02.430615 |
updated_at | 2024-12-11 02:57:16.773668 |
description | Library for using OAuth in dioxus |
homepage | |
repository | https://github.com/biyard/dioxus-oauth.git |
max_upload_size | |
id | 1444344 |
Cargo.toml error: | TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
[dependencies]
dioxus-oauth = { version = "0.1.0", path = "../dioxus-oauth" }
[features]
server = ["dioxus-oauth/server"]
web = ["dioxus-oauth/web"]
OAuthPopup
to your redirect URI.use dioxus_oauth::component::OAuthPopup;
#[derive(Clone, Routable, Debug, PartialEq)]
#[rustfmt::skip]
pub enum Route {
#[route("/oauth/code")]
OAuthPopup { },
}
#[component]
pub fn OAuthLoginPage() -> Element {
rsx! {
div {
onclick: move |_| {
#[cfg(feature = "web")]
{
spawn(async move {
let client = dioxus_oauth::prelude::OAuthClient::new(
env!("CLIENT_ID"),
env!("REDIRECT_URI"),
"https://kauth.kakao.com/oauth/authorize",
"https://kauth.kakao.com/oauth/token",
)
.set_openid_url("https://kauth.kakao.com/oauth/tokeninfo");
let code: String = match client.get_auth_code().await {
Ok(code) => code,
Err(e) => {
tracing::error!("Auth code failed: {:?}", e);
return;
}
};
let token_response: dioxus_oauth::prelude::TokenResponse =
match client.get_token(code.as_str()).await {
Ok(token_response) => token_response,
Err(e) => {
tracing::error!("Token response failed: {:?}", e);
return;
}
};
tracing::debug!("Token response: {:?}", token_response);
let oid_response: dioxus_oauth::prelude::OpenIdResponse =
match client.get_openid(&token_response.id_token).await {
Ok(oid_response) => oid_response,
Err(e) => {
tracing::error!("Token response failed: {:?}", e);
return;
}
};
tracing::debug!("OID response: {:?}", oid_response);
});
}
}
}
}
}