mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
* Added Support for Custom Auth using `client_id` and `scope` * fix: `Account::microsoft` and added lifetime to `Account::microsoft_with_custom_client_id` * Added function `with_microsoft_access_token_and_custom_client_id` * Removed Custom Scope. * I got carried away, and made scope also customizable, later realized no customization is needed. * Better Documentation and Minor fixes * Added Custom Scope * Added RpsTicket format for custom `client_id` * Moved to non-static str * fix example Co-authored-by: mat <27899617+mat-1@users.noreply.github.com> * fix doc grammer * changed function signature * fmt * fixed example * removed dead code * Removed `d=` insertion in `client_id` * removed unnecessary `mut` --------- Co-authored-by: mat <27899617+mat-1@users.noreply.github.com>
33 lines
1 KiB
Rust
Executable file
33 lines
1 KiB
Rust
Executable file
//! Authenticate with Microsoft and get a Minecraft profile, but don't cache and
|
|
//! use our own code to display the link code.
|
|
//!
|
|
//! If you still want it to cache, look at the code in [`azalea_auth::auth`] and
|
|
//! see how that does it.
|
|
|
|
use std::error::Error;
|
|
|
|
use azalea_auth::ProfileResponse;
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), Box<dyn Error>> {
|
|
env_logger::init();
|
|
|
|
let profile = auth().await?;
|
|
println!("Logged in as {}", profile.name);
|
|
|
|
Ok(())
|
|
}
|
|
|
|
// We will be using default `client_id` and `scope`
|
|
async fn auth() -> Result<ProfileResponse, Box<dyn Error>> {
|
|
let client = reqwest::Client::new();
|
|
|
|
let res = azalea_auth::get_ms_link_code(&client, None, None).await?;
|
|
println!(
|
|
"Go to {} and enter the code {}",
|
|
res.verification_uri, res.user_code
|
|
);
|
|
let msa = azalea_auth::get_ms_auth_token(&client, res, None).await?;
|
|
let auth_result = azalea_auth::get_minecraft_token(&client, &msa.data.access_token).await?;
|
|
Ok(azalea_auth::get_profile(&client, &auth_result.minecraft_access_token).await?)
|
|
}
|