Esempio n. 1
0
		public RequestData(HttpMethod method, string path, PostData<object> data, IConnectionConfigurationValues global, IRequestParameters local, IMemoryStreamFactory memoryStreamFactory)
#pragma warning disable CS0618 // Type or member is obsolete
			: this(method, path, data, global, (IRequestConfiguration)local?.RequestConfiguration, memoryStreamFactory)
#pragma warning restore CS0618 // Type or member is obsolete
		{
			this.CustomConverter = local?.DeserializationOverride;
			this.Path = this.CreatePathWithQueryStrings(path, this.ConnectionSettings, local);
		}
        public string GetUrl(string methodName, IRequestParameters parameters)
        {
            parameters.ParameterMap.Set("api_key", _simplickrConfigurationProvider.GetConfig().ApiKey);
            parameters.ParameterMap.Set("method", methodName);
            _simplickrFormatter.SetResponseFormat(parameters);

            return GetUrl(parameters.ParameterMap);
        }
        private async Task <AuthenticationResultEx> SendHttpMessageAsync(IRequestParameters requestParameters)
        {
            client = new AdalHttpClient(this.Authenticator.TokenUri, this.CallState)
            {
                Client = { BodyParameters = requestParameters }
            };
            TokenResponse tokenResponse = await client.GetResponseAsync <TokenResponse>().ConfigureAwait(false);

            return(tokenResponse.GetResult());
        }
Esempio n. 4
0
        private async Task <AuthenticationResultEx> SendHttpMessageAsync(IRequestParameters requestParameters)
        {
            var client = new AdalHttpClient(this.Authenticator.TokenUri, this.CallState)
            {
                Client = { BodyParameters = requestParameters }
            };
            TokenResponse tokenResponse = await client.GetResponseAsync <TokenResponse>(ClientMetricsEndpointType.Token);

            return(tokenResponse.GetResult());
        }
Esempio n. 5
0
        public static T GetAs <T>(this IRequestParameters callbackCommandParameter, string key, bool caseSensitive = false)
        {
            var result = callbackCommandParameter.Get(key, caseSensitive);

            if (result != null)
            {
                return((T)result);
            }

            return(default(T));
        }
Esempio n. 6
0
 public static Task <IReadOnlyList <T> > GetAllPagesAsync <T>(
     this IHalClient client,
     Link link,
     IRequestParameters request) where T : Resource
 {
     return(GetAllPagesAsync <T>(
                client,
                link,
                request,
                CancellationToken.None));
 }
Esempio n. 7
0
        public TResponse Invoke <TResponse>(string methodName, IRequestParameters parameters)
        {
            string url = _flickrRequestUrlProvider.GetUrl(methodName, parameters);

            Console.WriteLine(url);

            string response = _httpClient.Get(url);

            Console.WriteLine(response);

            return(_simplickrFormatter.Deserialize <TResponse>(response));
        }
Esempio n. 8
0
 /// <summary>
 /// Gets the <typeparamref name="T"/> resources that have changed since
 /// your application's last request.
 /// </summary>
 /// <param name="nextLink">The <see cref="Link"/> that was stored from
 /// your last request.</param>
 public static Task <ChangedResources <T> > GetChangedResourcesAsync <T>(
     this IHalClient client,
     Link nextLink,
     IRequestParameters request,
     CancellationToken cancellationToken) where T : Resource
 {
     return(client.GetChangedResourcesAsync <T>(
                nextLink,
                request?.Parameters,
                request?.Headers,
                cancellationToken));
 }
Esempio n. 9
0
		private string CreatePathWithQueryStrings(string path, IConnectionConfigurationValues global, IRequestParameters request = null)
		{
			//Make sure we append global query string as well the request specific query string parameters
			var copy = new NameValueCollection(global.QueryStringParameters);
			var formatter = new UrlFormatProvider(this.ConnectionSettings);
			if (request != null)
				copy.Add(request.QueryString.ToNameValueCollection(formatter));
			if (!copy.HasKeys()) return path;

			var queryString = copy.ToQueryString();
			path += queryString;
			return path;
		}
        public void GetIncumbent_WithoutRegionName_ArgumentNullException()
        {
            IRequestParameters requestParams = this.GetRequestParams(
                req =>
            {
                req.Params = new Parameters
                {
                    IncumbentType = "MVPD"
                };
            });

            this.whitespacesDataClient.GetIncumbents(requestParams);
        }
Esempio n. 11
0
 public RequestData(
     HttpMethod method, string path,
     PostData data,
     ITransportConfigurationValues global,
     IRequestParameters local,
     IMemoryStreamFactory memoryStreamFactory
     )
     : this(method, data, global, local?.RequestConfiguration, memoryStreamFactory)
 {
     _path = path;
     CustomResponseBuilder = local?.CustomResponseBuilder;
     PathAndQuery          = CreatePathWithQueryStrings(path, ConnectionSettings, local);
 }
        public void ExcludeIds_WithoutRegionName_ArgumentNullException()
        {
            IRequestParameters requestParams = this.GetRequestParams(
                req =>
            {
                req.Params = new Parameters
                {
                    DeviceId = Guid.NewGuid().ToString()
                };
            });

            this.whitespacesDataClient.ExcludeIds(requestParams);
        }
        public void TestGetChannelList()
        {
            IRequestParameters requestParams = this.GetRequestParams(
                req =>
            {
                req.RegionName = "United States";
                req.Params     = new Parameters
                {
                    IncumbentType = "MVPD",
                    Location      = new GeoLocation
                    {
                        Point = new Ellipse
                        {
                            Center = new Point
                            {
                                Latitude  = "40.5",
                                Longitude = "-74"
                            }
                        }
                    }
                };
            });

            RegionManagementResponse expectedResponse = this.GetResponse(
                response =>
            {
                response.Result = new Result
                {
                    ChannelInfo = new ChannelInfo[]
                    {
                        new ChannelInfo
                        {
                            ChannelId  = 2,
                            DeviceType = "Fixed"
                        },

                        new ChannelInfo
                        {
                            ChannelId  = 3,
                            DeviceType = "Fixed"
                        }
                    }
                };
            });

            this.httpClientManager.PostOf1RequestStringString <RegionManagementResponse>((request, regionName, accessToken) => expectedResponse);

            var actualResponse = this.whitespacesDataClient.GetChannelList(requestParams);

            Assert.AreEqual(expectedResponse.Result.ChannelInfo.Count(), actualResponse.ChannelInfo.Count());
        }
Esempio n. 14
0
        internal TResponse DoRequest <TRequest, TResponse>(TRequest p, IRequestParameters parameters, Action <IRequestConfiguration> forceConfiguration = null)
            where TRequest : class, IRequest
            where TResponse : class, IElasticsearchResponse, new()
        {
            if (forceConfiguration != null)
            {
                ForceConfiguration(p, forceConfiguration);
            }

            var url = p.GetUrl(ConnectionSettings);
            var b   = (p.HttpMethod == HttpMethod.GET || p.HttpMethod == HttpMethod.HEAD) ? null : new SerializableData <TRequest>(p);

            return(LowLevel.DoRequest <TResponse>(p.HttpMethod, url, b, parameters));
        }
Esempio n. 15
0
        public T CopyQueryStringValuesFrom(IRequestParameters requestParameters)
        {
            if (requestParameters == null)
            {
                return((T)this);
            }
            var from = requestParameters.QueryString;

            foreach (var k in from.Keys)
            {
                Self.QueryString[k] = from[k];
            }
            return((T)this);
        }
Esempio n. 16
0
        public T CopyQueryStringValuesFrom(IRequestParameters requestParameters)
        {
            if (requestParameters == null)
            {
                return((T)this);
            }
            IDictionary <string, object> from = requestParameters.QueryString;

            foreach (string k in from.Keys)
            {
                Self.QueryString[k] = from[k];
            }
            return((T)this);
        }
        public void TestGetNearByTvStations()
        {
            IRequestParameters requestParams = this.GetRequestParams(
                req =>
            {
                req.RegionName = "United States";
                req.Params     = new Parameters
                {
                    MVPDLocation = new Location
                    {
                        Latitude  = 38.62,
                        Longitude = -77.43
                    }
                };
            });

            var expectedResponse = this.GetResponse(
                response =>
            {
                response.Result = new Result
                {
                    SearchMVPDCallSigns = new MVPDCallSignsInfo[]
                    {
                        new MVPDCallSignsInfo
                        {
                            CallSign    = "WWPX-TV",
                            Channel     = 12,
                            Latitude    = 38.9503885573831,
                            Longitude   = -77.0797000775257,
                            ServiceType = "LD"
                        },
                        new MVPDCallSignsInfo
                        {
                            CallSign    = "WMDO-CA",
                            Channel     = 47,
                            Latitude    = 38.9401109541485,
                            Longitude   = -77.0813667929585,
                            ServiceType = "CA"
                        }
                    }
                };
            });

            this.httpClientManager.PostOf1RequestStringString <RegionManagementResponse>((request, regionName, accessToken) => expectedResponse);

            var actualResponse = this.whitespacesDataClient.GetChannelList(requestParams);

            Assert.AreEqual(expectedResponse.Result.SearchMVPDCallSigns.Count(), actualResponse.SearchMVPDCallSigns.Count());
        }
        private Uri CreateAuthorizationUri()
        {
            string loginHint = null;

            if (!userId.IsAnyUser &&
                (userId.Type == UserIdentifierType.OptionalDisplayableId ||
                 userId.Type == UserIdentifierType.RequiredDisplayableId))
            {
                loginHint = userId.Id;
            }

            IRequestParameters requestParameters = this.CreateAuthorizationRequest(loginHint);

            return(new Uri(new Uri(this.Authenticator.AuthorizationUri), "?" + requestParameters));
        }
Esempio n. 19
0
        public RequestPipeline(
            IConnectionConfigurationValues configurationValues,
            IDateTimeProvider dateTimeProvider,
            IMemoryStreamFactory memoryStreamFactory,
            IRequestParameters requestParameters)
        {
            this._settings            = configurationValues;
            this._connectionPool      = this._settings.ConnectionPool;
            this._connection          = this._settings.Connection;
            this._dateTimeProvider    = dateTimeProvider;
            this._memoryStreamFactory = memoryStreamFactory;

            this.RequestParameters    = requestParameters;
            this.RequestConfiguration = requestParameters?.RequestConfiguration;
            this.StartedOn            = dateTimeProvider.Now();
        }
    internal static void SetRequestMetaData(this IRequestParameters parameters, RequestMetaData requestMetaData)
    {
        if (parameters is null)
        {
            throw new ArgumentNullException(nameof(parameters));
        }

        if (requestMetaData is null)
        {
            throw new ArgumentNullException(nameof(requestMetaData));
        }

        parameters.RequestConfiguration ??= new RequestConfiguration();

        parameters.RequestConfiguration.RequestMetaData = requestMetaData;
    }
Esempio n. 21
0
        public void ExcludeIds_ValidRequest_ExcludeDeviceSuccessfully()
        {
            IRequestParameters requestParams = this.GetRequestParams(
                req =>
            {
                req.RegionName = "United States";
                req.Params     = new Parameters
                {
                    DeviceId = Guid.NewGuid().ToString()
                };
            });

            var actualResponse = this.whitespacesDataClient.ExcludeIds(requestParams);

            Assert.AreEqual("Excluded Id inserted successfully", actualResponse.Message);
        }
        public void GetNearByTvStations_WithoutRegionName_ArgumentNullException()
        {
            IRequestParameters requestParams = this.GetRequestParams(
                req =>
            {
                req.Params = new Parameters
                {
                    MVPDLocation = new Location
                    {
                        Latitude  = 38.62,
                        Longitude = -77.43
                    }
                };
            });

            this.whitespacesDataClient.GetNearByTvStations(requestParams);
        }
Esempio n. 23
0
        private RegionManagementResponse GetRegionManagementResponse(IRequestParameters requestParams, string methodName, string accessToken = null)
        {
            Request request = new Request
            {
                Method = methodName,
                Params = requestParams.Params
            };

            if (accessToken == null)
            {
                accessToken = requestParams.AccessToken;
            }

            Microsoft.WhiteSpaces.Common.Check.IsNotNull(requestParams.RegionName, "Region Name");

            return(this.httpManager.Post <RegionManagementResponse>(request, requestParams.RegionName, accessToken));
        }
        public void DeleteIncumbent_WithoutRegionName_ArgumentNullException()
        {
            IRequestParameters requestParams = this.GetRequestParams(
                req =>
            {
                req.Params = new Parameters
                {
                    IncumbentType           = "MVPD",
                    RegistrationDisposition = new RegistrationDisposition
                    {
                        RegId = "120824SPBR0000001"
                    }
                };
            });

            this.whitespacesDataClient.DeleteIncumbent(requestParams);
        }
        public void TestDeleteIncumbent()
        {
            IRequestParameters requestParams = this.GetRequestParams(
                req =>
            {
                req.RegionName  = "United States";
                req.AccessToken = "abcd";
                req.Params      = new Parameters
                {
                    IncumbentType = "MVPD",
                    Registrant    = new Vcard
                    {
                        Organization = new Organization
                        {
                            Text = "abcd"
                        }
                    },
                    MVPDLocation = new Location
                    {
                        Latitude  = 3,
                        Longitude = 3
                    },
                    TvSpectrum = new TvSpectrum
                    {
                        CallSign = "DTV",
                        Channel  = 24
                    }
                };
            });

            var expectedResponse = this.GetResponse(
                response =>
            {
                response.Result = new Result
                {
                    Message = "Incumbent Deleted successfully."
                };
            });

            this.httpClientManager.PostOf1RequestStringString <RegionManagementResponse>((request, regionName, accessToken) => expectedResponse);

            var actualResponse = this.whitespacesDataClient.DeleteIncumbent(requestParams);

            Assert.AreEqual(expectedResponse.Result.Message, actualResponse.Message);
        }
Esempio n. 26
0
        protected virtual void AddQueryParameters(IRequestParameters requestParameters)
        {
            var properties = requestParameters.GetType().GetProperties();

            foreach (var property in properties)
            {
                var value = property.GetValue(requestParameters);

                // If propery is null, continue with next.
                if (value == null)
                {
                    continue;
                }

                // If property is not null, continue with logic.

                var description = Attribute.IsDefined(property, typeof(DescriptionAttribute)) ?
                                  (Attribute.GetCustomAttribute(property, typeof(DescriptionAttribute)) as DescriptionAttribute).Description :
                                  property.Name;

                var isEnumerableNonString = typeof(IEnumerable).IsAssignableFrom(property.PropertyType) &&
                                            property.PropertyType != typeof(string);

                string parameter;
                // If is enumerable, convert to list of strings
                if (isEnumerableNonString)
                {
                    var type       = property.PropertyType;
                    var attributes = type.CustomAttributes;

                    var enumerable = value as List <string>;

                    parameter = value.ToString();

                    parameter = enumerable.Aggregate((x, y) => $"{x.ToString()},{y.ToString()}");
                }
                // Else convert to string
                else
                {
                    parameter = value.ToString();
                }

                _restRequest.AddQueryParameter(description, parameter);
            }
        }
		private string CreatePathWithQueryStrings(string path, IConnectionConfigurationValues global, IRequestParameters request = null)
		{

			//Make sure we append global query string as well the request specific query string parameters
			var copy = new NameValueCollection(global.QueryStringParameters);
			var formatter = new UrlFormatProvider(this.ConnectionSettings);
			if (request != null)
				copy.Add(request.QueryString.ToNameValueCollection(formatter));
			if (!copy.HasKeys()) return path;

			var queryString = copy.ToQueryString();
			var tempUri = new Uri("http://localhost:9200/" + path).Purify();
			if (tempUri.Query.IsNullOrEmpty())
				path += queryString;
			else 
				path += "&" + queryString.Substring(1, queryString.Length - 1);
			return path;
		}
Esempio n. 28
0
        private async Task <T> HandleDeviceAuthChallenge <T>(IHttpWebResponse response)
        {
            IDictionary <string, string> responseDictionary = this.ParseChallengeData(response);

            if (!responseDictionary.ContainsKey("SubmitUrl"))
            {
                responseDictionary["SubmitUrl"] = RequestUri;
            }

            string responseHeader = await PlatformPlugin.DeviceAuthHelper.CreateDeviceAuthChallengeResponse(responseDictionary).ConfigureAwait(false);

            IRequestParameters rp = this.Client.BodyParameters;

            this.Client = PlatformPlugin.HttpClientFactory.Create(CheckForExtraQueryParameter(responseDictionary["SubmitUrl"]), this.CallState);
            this.Client.BodyParameters           = rp;
            this.Client.Headers["Authorization"] = responseHeader;
            return(await this.GetResponseAsync <T>(false).ConfigureAwait(false));
        }
Esempio n. 29
0
        public void SubmitPawsInterference(IRequestParameters requestParams)
        {
            Request request = new Request
            {
                Method  = Microsoft.Whitespace.Entities.Constants.MethodNameInterferenceQuery,
                Id      = "1",
                JsonRpc = "2.0",
                Params  = requestParams.Params
            };

            PawsResponse response = this.httpManager.Post <PawsResponse>(request, requestParams.RegionName, null);

            var error = response.Error;

            if (error == null)
            {
                throw new ResponseErrorException(error.Type, error.Data, error.Code, error.Message);
            }
        }
Esempio n. 30
0
        public void GetNearByTvStations_ValidRequest_ReturnsNearestTVStations()
        {
            IRequestParameters requestParams = this.GetRequestParams(
                req =>
            {
                req.RegionName = "United States";
                req.Params     = new Parameters
                {
                    MVPDLocation = new Location
                    {
                        Latitude  = 38.62,
                        Longitude = -77.43
                    }
                };
            });

            var nearestTVStationsResponse = this.whitespacesDataClient.GetNearByTvStations(requestParams);

            Assert.IsTrue(nearestTVStationsResponse.SearchMVPDCallSigns.Count() > 0);
        }
Esempio n. 31
0
        internal virtual ElasticsearchPathInfo <TParameters> ToPathInfo(
            IConnectionSettingsValues settings,
            TParameters queryString
            )
        {
            var pathInfo = new ElasticsearchPathInfo <TParameters>();

            pathInfo.RequestParameters = queryString;
            var config = this._requestConfiguration;

            if (config != null)
            {
                IRequestParameters p = pathInfo.RequestParameters;
                p.RequestConfiguration = config;
            }

            SetRouteParameters(settings, pathInfo);

            UpdatePathInfo(settings, pathInfo);
            return(pathInfo);
        }
        private async Task <AuthenticationResultEx> SendHttpMessageAsync(IRequestParameters requestParameters)
        {
            string endpoint = this.Authenticator.TokenUri;

            endpoint = AddPolicyParameter(endpoint);

            var client = new MsalHttpClient(endpoint, this.CallState)
            {
                Client = { BodyParameters = requestParameters }
            };
            TokenResponse tokenResponse = await client.GetResponseAsync <TokenResponse>(ClientMetricsEndpointType.Token).ConfigureAwait(false);

            AuthenticationResultEx resultEx = tokenResponse.GetResultEx();

            if (resultEx.Result.ScopeSet == null || resultEx.Result.ScopeSet.Count == 0)
            {
                resultEx.Result.ScopeSet = this.Scope;
                PlatformPlugin.Logger.Information(this.CallState, "Scope was missing from the token response, so using developer provided scopes in the result");
            }

            return(resultEx);
        }
        public void TestExcludeChannel()
        {
            IRequestParameters requestParams = this.GetRequestParams(
                req =>
            {
                req.RegionName  = "United States";
                req.AccessToken = "abcd";
                req.Params      = new Parameters
                {
                    IncumbentType = "Fixed",
                    Location      = new GeoLocation
                    {
                        Point = new Ellipse
                        {
                            Center = new Point
                            {
                                Latitude  = "29.80",
                                Longitude = "-94.23"
                            }
                        }
                    }
                };
            });

            var expectedResponse = this.GetResponse(
                response =>
            {
                response.Result = new Result
                {
                    Message = "Incumbent Excluded successfully."
                };
            });

            this.httpClientManager.PostOf1RequestStringString <RegionManagementResponse>((request, regionName, accessToken) => expectedResponse);

            var actualResponse = this.whitespacesDataClient.ExcludeChannel(requestParams);

            Assert.AreEqual(expectedResponse.Result.Message, actualResponse.Message);
        }
Esempio n. 34
0
        public void ExcludeChannel_ValidRequest_ExcludesChannelSuccessfully()
        {
            IRequestParameters requestParams = this.GetRequestParams(
                req =>
            {
                req.RegionName = "United States";
                req.Params     = new Parameters
                {
                    IncumbentType = "MVPD",
                    TvSpectra     = new TvSpectrum[]
                    {
                        new TvSpectrum
                        {
                            Channel  = 23,
                            CallSign = "DTV"
                        }
                    },

                    Locations = new GeoLocation[]
                    {
                        new GeoLocation
                        {
                            Point = new Ellipse
                            {
                                Center = new Point
                                {
                                    Latitude  = "3",
                                    Longitude = "-1.3"
                                }
                            }
                        }
                    }
                };
            });

            var actualResponse = this.whitespacesDataClient.ExcludeChannel(requestParams);

            Assert.AreEqual("Channel Excluded Successfully.", actualResponse.Message);
        }
		public IRequestPipeline Create(IConnectionConfigurationValues configurationValues, IDateTimeProvider dateTimeProvider, IMemoryStreamFactory memorystreamFactory, IRequestParameters requestParameters) => 
			new RequestPipeline(this.Settings, this.DateTimeProvider, this.MemoryStreamFactory, requestParameters ?? new SearchRequestParameters());
Esempio n. 36
0
        /// <summary>
        /// <see cref="RecordBase.Init()" />
        /// </summary>
        protected override void Init()
        {
            var values = new Dictionary<string, byte[]>(new ServerRequestParameterComparer());

            using (var temp = new MemoryStream(this.Data, false))
            {
                do
                {
                    var nameLength = temp.ReadByte();
                    if (nameLength < 0)
                    {
                        break;
                    }

                    var valueLength = temp.ReadByte();
                    if (valueLength < 0)
                    {
                        break;
                    }

                    byte[] buffer;
                    int bytesRead;

                    buffer = new byte[nameLength];
                    bytesRead = temp.Read(buffer, 0, buffer.Length);
                    if (bytesRead != buffer.Length)
                    {
                        break;
                    }

                    var name = Encoding.UTF8.GetString(buffer).Trim();

                    buffer = new byte[valueLength];
                    bytesRead = temp.Read(buffer, 0, buffer.Length);
                    if (bytesRead != buffer.Length)
                    {
                        break;
                    }

                    var value = buffer;

                    if (values.ContainsKey(name))
                    {
                        values[name] = value;
                    }
                    else
                    {
                        values.Add(name, value);
                    }
                }
                while (true);
            }

            var @params = new ServerRequestParameters()
            {
                Parameters = new ReadOnlyDictionary<string, byte[]>(values),
            };

            this.Parameters = @params;
        }
		public IRequestPipeline Create(IConnectionConfigurationValues configurationValues, IDateTimeProvider dateTimeProvider, IMemoryStreamFactory memorystreamFactory, IRequestParameters requestParameters) =>
			new RequestPipeline(configurationValues, dateTimeProvider, memorystreamFactory, requestParameters);
        private async Task<List<AuthenticationResultEx>> SendHttpMessageAsync(IRequestParameters requestParameters, string extraQueryParameters = null)
        {
            string uri = this.Authenticator.TokenUri;
            if (!string.IsNullOrEmpty(extraQueryParameters))
            {
                uri = uri + "?" + extraQueryParameters;
            }

            var client = new AdalHttpClient(uri, this.CallState)
            {
                Client = {BodyParameters = requestParameters}
            };
            TokenResponse tokenResponse = await client.GetResponseAsync<TokenResponse>(ClientMetricsEndpointType.Token);

            return tokenResponse.GetResults();
        }
		public RequestData(HttpMethod method, string path, PostData<object> data, IConnectionConfigurationValues global, IRequestParameters local, IMemoryStreamFactory memoryStreamFactory)
			: this(method, path, data, global, (IRequestConfiguration)local?.RequestConfiguration, memoryStreamFactory)
		{
			this.CustomConverter = local?.DeserializationOverride;
			this.Path = this.CreatePathWithQueryStrings(path, this.ConnectionSettings, local);
		}
        private async Task<AuthenticationResultEx> SendHttpMessageAsync(IRequestParameters requestParameters)
        {
            var client = new AdalHttpClient(this.Authenticator.TokenUri, this.CallState) { Client = { BodyParameters = requestParameters } };
            TokenResponse tokenResponse = await client.GetResponseAsync<TokenResponse>(ClientMetricsEndpointType.Token);

            return tokenResponse.GetResult();
        }
        private async Task<AuthenticationResultEx> SendHttpMessageAsync(IRequestParameters requestParameters)
        {
            string endpoint = this.Authenticator.TokenUri;
            endpoint = AddPolicyParameter(endpoint);

            var client = new MsalHttpClient(endpoint, this.CallState) { Client = { BodyParameters = requestParameters } };
            TokenResponse tokenResponse = await client.GetResponseAsync<TokenResponse>(ClientMetricsEndpointType.Token).ConfigureAwait(false);

            AuthenticationResultEx resultEx = tokenResponse.GetResultEx();
            
            if (resultEx.Result.ScopeSet == null || resultEx.Result.ScopeSet.Count == 0)
            {
                resultEx.Result.ScopeSet = this.Scope;
                PlatformPlugin.Logger.Information(this.CallState, "Scope was missing from the token response, so using developer provided scopes in the result");
            }

            return resultEx;
        }