Beispiel #1
0
        public async Task <HttpResponseMessage> GetChannelListAsync(string localeInfo, Guid headendId)
        {
            CQSLineupRequestQuery query = new CQSLineupRequestQuery();
            var request = new HttpRequestMessage(HttpMethod.Get,
                                                 $"epg/{localeInfo}/lineups/{headendId}/channels");

            request.Headers.Add(Headers);
            request.AddQueryParameter(query.GetQuery());

            var response = await HttpClient.SendAsync(request);

            return(response);
        }
        public async Task <HttpResponseMessage> GetChannelListAsync(Guid lineupId)
        {
            EDSLineupRequestQuery query = new EDSLineupRequestQuery(lineupId);
            var request = new HttpRequestMessage(HttpMethod.Get,
                                                 $"media/{this.Config.Locale.Locale}/tvchannels");

            request.Headers.Add(Headers);
            request.AddQueryParameter(query.GetQuery());

            var response = await HttpClient.SendAsync(request);

            return(response);
        }
        public async Task <CatalogItemResponse> GetCatalogItemAsync(Guid productId)
        {
            CatalogItemRequestQuery query = new CatalogItemRequestQuery();

            var request = new HttpRequestMessage(HttpMethod.Get,
                                                 $"marketplacecatalog/v1/product/{Locale.Locale}/{productId}");

            request.AddQueryParameter(query.GetQuery());

            var response = await _httpClient.SendAsync(request);

            return(await response.Content.ReadAsJsonAsync <CatalogItemResponse>());
        }
        public async Task <ConversationsResponse> GetConversationsAsync(int skipItems = 0, int maxItems = 100)
        {
            MessageInboxRequestQuery query = new MessageInboxRequestQuery(
                skipItems, maxItems);
            var request = new HttpRequestMessage(HttpMethod.Get,
                                                 $"users/xuid({Config.XboxUserId})/inbox/conversations");

            request.Headers.Add(Headers);
            request.AddQueryParameter(query.GetQuery());

            var response = await HttpClient.SendAsync(request);

            return(await response.Content.ReadAsJsonAsync <ConversationsResponse>());
        }
        public async Task <CatalogOverviewResponse> GetCatalogOverviewAsync()
        {
            CatalogOverviewRequestQuery query = new CatalogOverviewRequestQuery(Locale);

            var request = new HttpRequestMessage(HttpMethod.Get, $"Catalog/Catalog.asmx/Query");
            List <Tuple <string, string> > q = query.GetQuery();

            // Query contains duplicate keys, hence following add-method
            q.ForEach(x => request.AddQueryParameter(x.Item1, x.Item2));

            var response = await _httpClient.SendAsync(request);

            return(await response.Content.ReadAsJsonAsync <CatalogOverviewResponse>());
        }
        /*
         * Static methods
         */

        /// <summary>
        /// Refreshes Access- and RefreshToken via the provided RefreshToken
        /// </summary>
        /// <param name="refreshToken">Windows Live refresh token</param>
        /// <returns>The gathered WindowsLiveResponse.</returns>
        public static async Task <WindowsLiveResponse> RefreshLiveTokenAsync(
            RefreshToken refreshToken)
        {
            logger.LogTrace("RefreshLiveTokenAsync() called");
            HttpClient client = ClientFactory("https://login.live.com/");

            var request    = new HttpRequestMessage(HttpMethod.Get, "oauth20_token.srf");
            var parameters = new Model.WindowsLiveRefreshQuery(refreshToken);

            request.AddQueryParameter(parameters.GetQuery());

            var response = (await client.SendAsync(request)).EnsureSuccessStatusCode();

            return(await response.Content.ReadAsJsonAsync <WindowsLiveResponse>(JsonNamingStrategy.SnakeCase));
        }
Beispiel #7
0
        public async Task <HttpResponseMessage> GetScheduleAsync(string localeInfo, Guid headendId,
                                                                 DateTime startDate, int durationMinutes,
                                                                 int channelSkip, int channelCount)
        {
            CQSScheduleRequestQuery query = new CQSScheduleRequestQuery(
                startDate, durationMinutes, channelSkip, channelCount);
            var request = new HttpRequestMessage(HttpMethod.Get,
                                                 $"epg/{localeInfo}/lineups/{headendId}/programs");

            request.Headers.Add(Headers);
            request.AddQueryParameter(query.GetQuery());

            var response = await HttpClient.SendAsync(request);

            return(response);
        }
        private async Task <ProfileResponse> _GetProfileAsync(string resource, ProfileSetting[] settings = null)
        {
            var request = new HttpRequestMessage(HttpMethod.Get, resource);

            ProfileSetting[] profileSettings = settings != null ? settings : new ProfileSetting[]
            {
                ProfileSetting.AppDisplayName, ProfileSetting.Gamerscore,
                ProfileSetting.Gamertag, ProfileSetting.PublicGamerpic,
                ProfileSetting.XboxOneRep, ProfileSetting.RealName
            };
            ProfileRequestQuery query = new ProfileRequestQuery(profileSettings);

            request.Headers.Add(Headers);
            request.AddQueryParameter(query.GetQuery());

            var response = await HttpClient.SendAsync(request);

            return(await response.Content.ReadAsJsonAsync <ProfileResponse>());
        }
Beispiel #9
0
        /// <summary>
        /// Poll MS Authenticator v2 SessionState.
        /// Polling happens for maximum of 120 seconds if Authorization is not approved by the Authenticator App.
        /// It will return earlier if request gets approved/rejected.
        /// </summary>
        /// <returns>Returns current session state</returns>
        private async Task <Model.TwoFactorAuthSessionState> PollSessionState()
        {
            string pollingUrl = null;

            foreach (var value in _serverData.Values)
            {
                string currentVal = value as string;
                if (!String.IsNullOrEmpty(currentVal) &&
                    currentVal.StartsWith("https://login.live.com/GetSessionState.srf"))
                {
                    pollingUrl = currentVal;
                }
            }
            if (String.IsNullOrEmpty(pollingUrl))
            {
                throw new Exception("Cannot find polling URL for TOTPv2 session state");
            }

            DateTime maxWaitTime = DateTime.Now + TimeSpan.FromSeconds(MaxTOTPv2WaitTimeSeconds);

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, pollingUrl);

            request.AddQueryParameter("slk", SessionLookupKey);

            logger.LogInformation("Polling Authenticator v2 Verification for {} seconds", MaxTOTPv2WaitTimeSeconds);

            Model.TwoFactorAuthSessionState sessionState = Model.TwoFactorAuthSessionState.PENDING;
            while (DateTime.Now < maxWaitTime)
            {
                var pollResponse = await _client.SendAsync(request);

                var gifData = await pollResponse.Content.ReadAsByteArrayAsync();

                sessionState = VerifyAuthenticatorV2Gif(gifData);
                if (sessionState != Model.TwoFactorAuthSessionState.PENDING)
                {
                    break;
                }
                await Task.Delay(1 * 1000);
            }

            return(sessionState);
        }