yggdrasil-authenticator

Crates.ioyggdrasil-authenticator
lib.rsyggdrasil-authenticator
version0.1.0
sourcesrc
created_at2024-09-11 15:16:37.622924
updated_at2024-09-11 15:16:37.622924
descriptionRust library for authenticating using Yggdrasil API.
homepagehttps://github.com/MizukiLab/yggdrasil-authenticator
repositoryhttps://github.com/MizukiLab/yggdrasil-authenticator
max_upload_size
id1372011
size44,300
CookedBunny (Rabbit0w0)

documentation

https://docs.rs/yggdrasil-authenticator

README

Yggdrasil Authenticator Library


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

Features

  • AuthClient: The main client for handling authentication operations.
  • JSON Models: Structs for serializing/deserializing request and response data, including agents, profiles, users, and errors.
  • Error Handling: Custom error types for handling authentication failures.

Sample Code


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(())
}

Commit count: 0

cargo fmt