get_ms_auth_token

Function get_ms_auth_token 

Source
pub async fn get_ms_auth_token(
    client: &Client,
    res: DeviceCodeResponse,
    client_id: Option<&str>,
) -> Result<ExpiringValue<AccessTokenResponse>, GetMicrosoftAuthTokenError>
Expand description

Wait until the user logged into Microsoft with the given code.

You get the device code response needed for this function from get_ms_link_code.

You should pass the response from this to get_minecraft_token.

Examples found in repository?
azalea-auth/examples/auth_manual.rs (line 30)
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}