public void CreateRequestXSTS() { string expect = TestData["XSTSRequestBody.json"]; UserToken token = new UserToken() { Jwt = "eWaoksdijsdfeefes" }; XSTSRequest request = new XSTSRequest(token); string body = NewtonsoftJsonSerializer.Default.Serialize(request); Assert.AreEqual(body, expect); }
/// <summary> /// Authenticates to XAST (title.auth.xboxlive.com) via Access- and DeviceToken. /// </summary> /// <param name="userToken">Xbox Live user token</param> /// <param name="deviceToken">Xbox Live device token</param> /// <param name="titleToken">Xbox Live title token</param> /// <returns>Returns the Xbox Live X-token</returns> public static async Task <XToken> AuthenticateXSTSAsync(UserToken userToken, DeviceToken deviceToken = null, TitleToken titleToken = null) { logger.LogTrace("AuthenticateXSTSAsync() called"); HttpClient client = ClientFactory("https://xsts.auth.xboxlive.com/"); var request = new HttpRequestMessage(HttpMethod.Post, "xsts/authorize"); var requestBody = new XSTSRequest(userToken, deviceToken: deviceToken, titleToken: titleToken); request.Headers.Add("x-xbl-contract-version", "1"); request.Content = new JsonContent(requestBody); var response = await client.SendAsync(request); var data = await response.Content.ReadAsJsonAsync <XASResponse>(); return(new XToken(data)); }