-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Finish auth * Clippy + fix avatar on alts * add retrying to entitlement request
- Loading branch information
1 parent
260744c
commit e39635c
Showing
19 changed files
with
69 additions
and
46 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "theseus" | ||
version = "0.6.2" | ||
version = "0.6.3" | ||
authors = ["Jai A <[email protected]>"] | ||
edition = "2018" | ||
|
||
|
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 |
---|---|---|
@@ -1,34 +1,42 @@ | ||
use serde::Deserialize; | ||
use serde_json::json; | ||
|
||
use super::auth_retry; | ||
|
||
const MCSERVICES_AUTH_URL: &str = | ||
"https://api.minecraftservices.com/launcher/login"; | ||
"https://api.minecraftservices.com/authentication/login_with_xbox"; | ||
|
||
#[derive(Deserialize)] | ||
pub struct BearerTokenResponse { | ||
access_token: String, | ||
expires_in: i64, | ||
} | ||
|
||
#[tracing::instrument] | ||
pub async fn fetch_bearer(token: &str, uhs: &str) -> crate::Result<String> { | ||
pub async fn fetch_bearer( | ||
token: &str, | ||
uhs: &str, | ||
) -> crate::Result<(String, i64)> { | ||
let body = auth_retry(|| { | ||
let client = reqwest::Client::new(); | ||
client | ||
.post(MCSERVICES_AUTH_URL) | ||
.header("Accept", "application/json") | ||
.json(&json!({ | ||
"xtoken": format!("XBL3.0 x={};{}", uhs, token), | ||
"platform": "PC_LAUNCHER" | ||
"identityToken": format!("XBL3.0 x={};{}", uhs, token), | ||
})) | ||
.send() | ||
}) | ||
.await? | ||
.text() | ||
.await?; | ||
|
||
serde_json::from_str::<serde_json::Value>(&body)? | ||
.get("access_token") | ||
.and_then(serde_json::Value::as_str) | ||
.map(String::from) | ||
.ok_or( | ||
serde_json::from_str::<BearerTokenResponse>(&body) | ||
.map(|x| (x.access_token, x.expires_in)) | ||
.map_err(|_| { | ||
crate::ErrorKind::HydraError(format!( | ||
"Response didn't contain valid bearer token. body: {body}" | ||
)) | ||
.into(), | ||
) | ||
.into() | ||
}) | ||
} |
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "theseus_cli" | ||
version = "0.6.2" | ||
version = "0.6.3" | ||
authors = ["Jai A <[email protected]>"] | ||
edition = "2018" | ||
|
||
|
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
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