Crates.io | mc_auth |
lib.rs | mc_auth |
version | 0.1.0 |
source | src |
created_at | 2023-09-11 23:01:28.311581 |
updated_at | 2023-09-11 23:01:28.311581 |
description | A simple library for authenticating with Mojang's authentication servers. |
homepage | |
repository | https://github.com/minecraft-rs/auth |
max_upload_size | |
id | 970204 |
size | 39,461 |
Xbox live authentication flow for Minecraft in Rust.
In order to create tools for Minecraft based on rust that implement the user profile it is necessary to first authenticate the user through Microsoft servers. With this library you can do it in just 5 lines of code.
You must first have an account in Azure and then register an application in Azure Active Directory.
use mc_auth::AuthFlow;
fn main() {
let mut auth = AuthFlow::new("9c1f1f43-58d5-4b7a-af0d-4e487f073441");
let code_res = auth.request_code().unwrap();
println!(
"Open this link in your browser {} and enter the following code: {}\nWaiting authentication...",
code_res.verification_uri, code_res.user_code
);
auth.wait_for_login().unwrap();
auth.login_in_xbox_live().unwrap();
let minecraft = auth.login_in_minecraft().unwrap();
println!("Logged in:");
println!("Bearer token: {}", minecraft.access_token);
println!("UUID: {}", minecraft.username);
}
Feel free to contribute to the development of the library.