Exemplo n.º 1
0
        public static TitleToken AuthenticateXAST(AccessToken accessToken,
                                                  DeviceToken deviceToken)
        {
            RestClientEx  client  = ClientFactory("https://title.auth.xboxlive.com");
            RestRequestEx request = new RestRequestEx("title/authenticate", Method.POST);

            request.AddHeader("x-xbl-contract-version", "1");
            request.AddJsonBody(new XASTRequest(accessToken, deviceToken));
            IRestResponse <XASResponse> response = client.Execute <XASResponse>(request);

            return(new TitleToken(response.Data));
        }
Exemplo n.º 2
0
        public static XToken AuthenticateXSTS(UserToken userToken,
                                              DeviceToken deviceToken = null,
                                              TitleToken titleToken   = null)
        {
            RestClientEx  client  = ClientFactory("https://xsts.auth.xboxlive.com");
            RestRequestEx request = new RestRequestEx("xsts/authorize", Method.POST);

            request.AddHeader("x-xbl-contract-version", "1");
            request.AddJsonBody(new XSTSRequest(userToken,
                                                deviceToken: deviceToken,
                                                titleToken: titleToken));
            IRestResponse <XASResponse> response = client.Execute <XASResponse>(request);

            return(new XToken(response.Data));
        }
        /// <summary>
        /// Authenticates to XAST (title.auth.xboxlive.com) via Access- and DeviceToken.
        /// </summary>
        /// <param name="accessToken">Windows Live access token</param>
        /// <param name="deviceToken">Xbox Live device token</param>
        /// <returns>Returns the Xbox Live title token</returns>
        public static async Task <TitleToken> AuthenticateXASTAsync(AccessToken accessToken,
                                                                    DeviceToken deviceToken)
        {
            logger.LogTrace("AuthenticateXASTAsync() called");
            HttpClient client      = ClientFactory("https://title.auth.xboxlive.com/");
            var        request     = new HttpRequestMessage(HttpMethod.Post, "title/authenticate");
            var        requestBody = new XASTRequest(accessToken, deviceToken);

            request.Headers.Add("x-xbl-contract-version", "1");
            request.Content = new JsonContent(requestBody);

            var response = (await client.SendAsync(request)).EnsureSuccessStatusCode();
            var data     = await response.Content.ReadAsJsonAsync <XASResponse>();

            return(new TitleToken(data));
        }
        /// <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));
        }
 public static XToken AuthenticateXSTS(UserToken userToken,
                                       DeviceToken deviceToken = null,
                                       TitleToken titleToken   = null)
 {
     return(AuthenticateXSTSAsync(userToken, deviceToken, titleToken).GetAwaiter().GetResult());
 }
 public static TitleToken AuthenticateXAST(AccessToken accessToken, DeviceToken deviceToken)
 {
     return(AuthenticateXASTAsync(accessToken, deviceToken).GetAwaiter().GetResult());
 }