pub async fn get_ms_link_code(
client: &Client,
client_id: Option<&str>,
scope: Option<&str>,
) -> Result<DeviceCodeResponse, GetMicrosoftAuthTokenError>Expand description
Get the Microsoft link code that’s shown to the user for logging into Microsoft.
You should call get_ms_auth_token right after showing the user the
verification_uri and
user_code.
If showing the link code in the terminal is acceptable, then you can just
use interactive_get_ms_auth_token instead.
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 minecraft = azalea_auth::get_minecraft_token(client, &msa.data.access_token).await?;
let profile = azalea_auth::get_profile(&client, &minecraft.minecraft_access_token).await?;Examples found in repository?
azalea-auth/examples/auth_manual.rs (line 25)
22async fn auth() -> Result<ProfileResponse, Box<dyn Error>> {
23 let client = reqwest::Client::new();
24
25 let res = azalea_auth::get_ms_link_code(&client, None, None).await?;
26 println!(
27 "Go to {} and enter the code {}",
28 res.verification_uri, res.user_code
29 );
30 let msa = azalea_auth::get_ms_auth_token(&client, res, None).await?;
31 let auth_result = azalea_auth::get_minecraft_token(&client, &msa.data.access_token).await?;
32 Ok(azalea_auth::get_profile(&client, &auth_result.minecraft_access_token).await?)
33}