Crates.io | yggdrasil-authenticator |
lib.rs | yggdrasil-authenticator |
version | 0.1.0 |
source | src |
created_at | 2024-09-11 15:16:37.622924 |
updated_at | 2024-09-11 15:16:37.622924 |
description | Rust library for authenticating using Yggdrasil API. |
homepage | https://github.com/MizukiLab/yggdrasil-authenticator |
repository | https://github.com/MizukiLab/yggdrasil-authenticator |
max_upload_size | |
id | 1372011 |
size | 44,300 |
This Rust library provides an interface for interacting with Yggdrasil's authentication system. It includes models for handling authentication requests, responses, and errors, as well as a client for sending HTTP requests to authenticate, refresh, validate, and sign out users.
Implemented Standard: authlib-injector
use yggdrasil_authenticator::auth_agent::AuthAgent;
use yggdrasil_authenticator::client::client::AuthClient;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let client = AuthClient::new(
"https://myauthserver.com/auth-endpoint".to_string(), // No "/" at the end
None, // No proxy URL
);
// Authenticate a user
let agent = AuthAgent::new("Minecraft".to_string(), 1);
let auth_response = client
.authenticate(agent, "username", "password", "client_token", true)
.await?;
println!("Access Token: {}", auth_response.access_token);
// Refresh token
let refresh_response = client
.refresh(&auth_response.access_token, &auth_response.client_token, true, None)
.await?;
println!("New Access Token: {}", refresh_response.access_token);
Ok(())
}