internal static async Task <TokenResponse> ExecuteAsync(
            this ImpersonationRequest request, HttpClient httpClient, string url,
            IClock clock, ILogger logger, CancellationToken cancellationToken)
        {
            var response = await request.ExecuteAsync(httpClient, url, cancellationToken).ConfigureAwait(false);

            return(await TokenResponse.FromHttpResponseAsync(response, clock, logger).ConfigureAwait(false));
        }
        internal static async Task <TResponse> ExecuteAsync <TResponse>(
            this ImpersonationRequest request, HttpClient httpClient, string url, CancellationToken cancellationToken)
        {
            var response = await request.ExecuteAsync(httpClient, url, cancellationToken).ConfigureAwait(false);

            response.EnsureSuccessStatusCode();
            return(await NewtonsoftJsonSerializer.Instance.DeserializeAsync <TResponse>(
                       await response.Content.ReadAsStreamAsync().ConfigureAwait(false), cancellationToken).ConfigureAwait(false));
        }
        internal static async Task <HttpResponseMessage> ExecuteAsync(
            this ImpersonationRequest request, HttpClient httpClient, string url, CancellationToken cancellationToken)
        {
            var httpRequest = new HttpRequestMessage(HttpMethod.Post, url)
            {
                Content = new StringContent(NewtonsoftJsonSerializer.Instance.Serialize(request), Encoding.UTF8, "application/json")
            };

            return(await httpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false));
        }