Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mizukilab/yggdrasil-authenticator
Yggdrasil API library in Rust
https://github.com/mizukilab/yggdrasil-authenticator
auth minecraft minecraft-launcher-library rust rustlang yggdrasil yggdrasil-api yggdrasil-minecraft-login
Last synced: 4 months ago
JSON representation
Yggdrasil API library in Rust
- Host: GitHub
- URL: https://github.com/mizukilab/yggdrasil-authenticator
- Owner: MizukiLab
- License: apache-2.0
- Created: 2024-09-09T16:13:58.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-09-11T15:17:23.000Z (5 months ago)
- Last Synced: 2024-10-12T13:21:18.841Z (4 months ago)
- Topics: auth, minecraft, minecraft-launcher-library, rust, rustlang, yggdrasil, yggdrasil-api, yggdrasil-minecraft-login
- Language: Rust
- Homepage:
- Size: 35.2 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
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](https://github.com/yushijinhun/authlib-injector/wiki/Yggdrasil-%E6%9C%8D%E5%8A%A1%E7%AB%AF%E6%8A%80%E6%9C%AF%E8%A7%84%E8%8C%83)
## 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.## Usage
Add the library to your `Cargo.toml`:
```toml
[dependencies]
yggdrasil-authenticator = "0.1.0"
```## Sample Code
```rust
use yggdrasil_authenticator::auth_agent::AuthAgent;
use yggdrasil_authenticator::client::client::AuthClient;
use std::error::Error;#[tokio::main]
async fn main() -> Result<(), Box> {
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(())
}```