-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend documentation, fix code examples
- Loading branch information
Showing
10 changed files
with
533 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
use serde_json::json; | ||
use xal::{ | ||
extensions::JsonExDeserializeMiddleware, flows, oauth2::TokenResponse, AccessTokenPrefix, | ||
Error, XalAuthenticator, | ||
}; | ||
use xal_examples::auth_main; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Error> { | ||
let app_params = xal::app_params::MC_BEDROCK_SWITCH(); | ||
let client_params = xal::client_params::CLIENT_NINTENDO(); | ||
|
||
let ts = auth_main( | ||
app_params, | ||
client_params, | ||
"RETAIL".into(), | ||
AccessTokenPrefix::None, | ||
flows::CliCallbackHandler, | ||
) | ||
.await?; | ||
|
||
let mut authenticator = XalAuthenticator::from(ts.clone()); | ||
let xsts_mc_services = authenticator | ||
.get_xsts_token( | ||
ts.device_token.as_ref(), | ||
ts.title_token.as_ref(), | ||
ts.user_token.as_ref(), | ||
"rp://api.minecraftservices.com/", | ||
) | ||
.await?; | ||
|
||
let identity_token = xsts_mc_services.authorization_header_value(); | ||
println!("identityToken: {identity_token}"); | ||
|
||
/* Minecraft stuff */ | ||
// Fetch minecraft token | ||
let mc_token = reqwest::Client::new() | ||
.post("https://api.minecraftservices.com/authentication/login_with_xbox") | ||
.json(&json!({"identityToken": identity_token})) | ||
.send() | ||
.await? | ||
.json_ex::<xal::oauth2::basic::BasicTokenResponse>() | ||
.await?; | ||
println!("MC: {mc_token:?}"); | ||
|
||
// Get minecraft entitlements | ||
let entitlements = reqwest::Client::new() | ||
.get("https://api.minecraftservices.com/entitlements/mcstore") | ||
.bearer_auth(mc_token.access_token().secret()) | ||
.send() | ||
.await? | ||
.text() | ||
.await?; | ||
println!("Entitlements: {entitlements}"); | ||
|
||
// Get minecraft profile | ||
let profile = reqwest::Client::new() | ||
.get("https://api.minecraftservices.com/minecraft/profile") | ||
.bearer_auth(mc_token.access_token().secret()) | ||
.send() | ||
.await? | ||
.text() | ||
.await?; | ||
println!("Profile: {profile}"); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.