Exemplo n.º 1
0
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            // request the access token
            var accessToken = await _authServerConnect.RequestClientCredentialsTokenAsync();

            // set the bearer token to the outgoing request as Authentication Header
            request.SetBearerToken(accessToken);

            // Proceed calling the inner handler, that will actually send the requestto our protected api
            return(await base.SendAsync(request, cancellationToken));
        }
Exemplo n.º 2
0
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            // acceso al token de seguridad
            var accessToken = await _authServerConnect.RequestClientCredentialsTokenAsync();

            // establecer el Authentication Header
            request.SetBearerToken(accessToken);

            // llamar al handler del token
            return(await base.SendAsync(request, cancellationToken));
        }