コード例 #1
0
        public WhispirApiHttpMessageHandler(WhispirApiHttpClientOptions options, HttpMessageHandler innerHandler = null)
        {
            var basicAuthHandler = new BasicAuthenticatedHttpMessageHandler(
                new BasicAuthenticatedHttpClientOptions
            {
                UserId   = options.Username,
                Password = options.Password
            },
                innerHandler
                );

            var customHeaderAuthHandler = new CustomHeaderAuthenticatedHttpMessageHandler(
                new CustomHeaderAuthenticatedHttpClientOptions
            {
                Name  = "x-api-key",
                Value = options.ApiKey
            },
                basicAuthHandler
                );

            var queryStringAuthHandler = new QueryStringParameterAuthenticatedHttpMessageHandler(
                new QueryStringParameterAuthenticatedHttpClientOptions
            {
                Name  = "apikey",
                Value = options.ApiKey
            },
                customHeaderAuthHandler
                );

            InnerHandler = queryStringAuthHandler;
        }
コード例 #2
0
        public static HttpClient GetClient(WhispirApiHttpClientOptions options, HttpMessageHandler innerHandler = null)
        {
            var msgHandler = new WhispirApiHttpMessageHandler(options, innerHandler);

            return(new HttpClient(msgHandler));
        }