示例#1
0
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var auth = request.Headers.Authorization;

            if (auth != null)
            {
                var token = await _provider.GetToken().ConfigureAwait(false);

                request.Headers.Authorization = new AuthenticationHeaderValue(auth.Scheme, token);
            }

            if (request.Headers.Remove(Constants.AccountIdHeaderName))
            {
                var id = _provider.GetAccountId();
                request.Headers.Add(Constants.AccountIdHeaderName, id);
            }

            return(await base.SendAsync(request, cancellationToken).ConfigureAwait(false));
        }