Last active
May 19, 2021 16:49
-
-
Save TechWatching/54e992e0dcc6c30436902b8f7672e599 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UserApiAuthenticationHandler : DelegatingHandler | |
{ | |
private readonly IUserApiAuthenticationService _authenticationService; | |
public UserApiAuthenticationHandler(IUserApiAuthenticationService authenticationService) | |
{ | |
_authenticationService = authenticationService; | |
} | |
protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationTokencancellationToken) | |
{ | |
var token = await _authenticationService.RetrieveToken(); | |
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token); | |
return await base.SendAsync(request, cancellationToken); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment