private async Task <AuthResponse <XuiDisplayClaims <XstsXui> > > DoXsts(HttpClient client, AuthResponse <DeviceDisplayClaims> deviceToken, AuthResponse <TitleDisplayClaims> title, string userToken) { //var key = EcDsa.ExportParameters(false); var authRequest = new AuthRequest { RelyingParty = "https://multiplayer.minecraft.net/", TokenType = "JWT", Properties = new Dictionary <string, object>() { { "UserTokens", new string[] { userToken } }, { "DeviceToken", deviceToken.Token }, { "TitleToken", title.Token }, { "SandboxId", "RETAIL" }, { "ProofKey", new ProofKey(X, Y) } } }; using (var r = new HttpRequestMessage(HttpMethod.Post, XblAuth)) { r.Headers.Add("User-Agent", "MCPE/Android"); r.Headers.Add("Client-Version", McpeProtocolInfo.ProtocolVersion.ToString()); SetHeadersAndContent(r, authRequest); using (var response = await client.SendAsync(r, HttpCompletionOption.ResponseContentRead) .ConfigureAwait(false)) { response.EnsureSuccessStatusCode(); var rawResponse = await response.Content.ReadAsStringAsync(); // Console.WriteLine(rawResponse); // Console.WriteLine(); return(JsonConvert.DeserializeObject <AuthResponse <XuiDisplayClaims <XstsXui> > >(rawResponse)); //Log.Debug($"Xsts Auth: {rawResponse}"); } } }
private async Task <AuthResponse <TitleDisplayClaims> > DoTitleAuth(HttpClient client, AuthResponse <DeviceDisplayClaims> deviceToken, string accessToken) { var authRequest = new AuthRequest { RelyingParty = "http://auth.xboxlive.com", TokenType = "JWT", Properties = new Dictionary <string, object>() { { "AuthMethod", "RPS" }, { "DeviceToken", deviceToken.Token }, { "RpsTicket", $"t={accessToken}" }, { "SiteName", "user.auth.xboxlive.com" }, { "ProofKey", new ProofKey(X, Y) } } }; using (var r = new HttpRequestMessage(HttpMethod.Post, TitleAuth)) { SetHeadersAndContent(r, authRequest); using (var response = await client .SendAsync(r, HttpCompletionOption.ResponseContentRead) .ConfigureAwait(false)) { response.EnsureSuccessStatusCode(); return (JsonConvert.DeserializeObject <AuthResponse <TitleDisplayClaims> >( await response.Content.ReadAsStringAsync())); } } }
public async Task <bool> RequestMinecraftChain(HttpClient client, AuthResponse <XuiDisplayClaims <XstsXui> > token) { var b = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(MinecraftKeyPair.Public).GetEncoded() .EncodeBase64(); var body = new MCChainPostData() { IdentityPublicKey = b }; using (var r = new HttpRequestMessage(HttpMethod.Post, MinecraftAuthUrl)) { r.Headers.Add("Authorization", $"XBL3.0 x={token.DisplayClaims.Xui[0].UserHash};{token.Token}"); //r.Headers.Add("User-Agent", "MCPE/Android"); r.Headers.Add("Client-Version", McpeProtocolInfo.ProtocolVersion.ToString()); SetHeadersAndContent(r, body); try { using (var response = await client.SendAsync(r, HttpCompletionOption.ResponseContentRead) .ConfigureAwait(false)) { response.EnsureSuccessStatusCode(); var rawResponse = await response.Content.ReadAsStringAsync(); DecodedChain = new ChainData(); dynamic a = JObject.Parse(rawResponse); var chain = ((JArray)a.chain).Values <string>().ToArray(); DecodedChain.Chain = new CertificateData[chain.Length]; for (int i = 0; i < chain.Length; i++) { var element = chain[i]; try { DecodedChain.Chain[i] = JWT.Payload <CertificateData>(element); } catch (Exception ex) { Log.Error($"Could not parse chain element: {ex.ToString()}"); } } //DecodedChain = JsonConvert.DeserializeObject<ChainData>(rawResponse); MinecraftChain = Encoding.UTF8.GetBytes(rawResponse); // File.WriteAllBytes("/home/kenny/xbox.json", MinecraftChain); // //Log.Debug($"Chain: {rawResponse}"); } } catch (Exception ex) { Log.Warn($"AHHH: {ex.ToString()}"); return(false); } } // //Log.Debug($"Xbox login processed!"); return(true); }