1 unstable release
0.1.0 | Sep 11, 2023 |
---|
#867 in Authentication
12KB
189 lines
MC Auth
Xbox live authentication flow for Minecraft in Rust.
Why?
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.
Prepare
You must first have an account in Azure and then register an application in Azure Active Directory.
- Go to Portal Code and register or log in.
- Once in your account, go to the "Azure Active Directory" service.
- On the service page go to the application registration section in the sidebar.
- Create a new application, name it whatever you want and copy the Client ID. You will need it to use this library.
- Configure your app, in the api permissions section make sure you have the following permissions active: "XboxLive.signin offline_access".
Usage
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);
}
Contribution
Feel free to contribute to the development of the library.
Dependencies
~4–16MB
~222K SLoC