-
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.
- Loading branch information
Showing
9 changed files
with
786 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use env_logger::Env; | ||
use xal::{ | ||
cvlib::CorrelationVector, | ||
extensions::{ | ||
CorrelationVectorReqwestBuilder, LoggingReqwestRequestHandler, | ||
LoggingReqwestResponseHandler, SigningReqwestBuilder, | ||
}, | ||
Error, RequestSigner, TokenStore, | ||
}; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
env_logger::Builder::from_env(Env::default().default_filter_or("trace")).init(); | ||
|
||
// Load tokens from JSON | ||
let token_store = TokenStore::load_from_file("tokens.json")?; | ||
|
||
// Create new instances of Correlation vector and request signer | ||
let mut cv = CorrelationVector::new(); | ||
let mut signer = RequestSigner::new(); | ||
|
||
// Check if XSTS token exists | ||
let xsts_token = token_store | ||
.authorization_token | ||
.ok_or(Error::GeneralError("No XSTS token was acquired".into()))?; | ||
|
||
// Send a http request | ||
// Request will get signed and MS-CV header populated | ||
let userpresence = reqwest::Client::new() | ||
.get("https://userpresence.xboxlive.com/users/me?level=all") | ||
.header("x-xbl-contract-version", "3") | ||
.header("Authorization", xsts_token.authorization_header_value()) | ||
.add_cv(&mut cv)? | ||
.sign(&mut signer, None) | ||
.await? | ||
.log() | ||
.await? | ||
.send() | ||
.await? | ||
.log() | ||
.await?; | ||
|
||
println!("{:?}", userpresence); | ||
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
Oops, something went wrong.