A DelegatingHandler inspects or modifies HTTP requests before passing them to another handler. Attach one to an HttpClient to apply changes automatically instead of repeating them at every API call. section 8.3.2
Use a delegating handler to apply authentication and other request policies consistently:
- Inherit from DelegatingHandler and override SendAsync. section 8.3.2
- Modify the HttpRequestMessage, such as by adding an access-token header, then call the base method. section 8.3.2
- Register the handler and attach it to a named HttpClient through IHttpClientFactory. section 8.3.3
- Chain multiple handlers with AddHttpMessageHandler when separate request modifications or a controlled processing order are useful. section 8.3.3
Automatically adding an access token
An AuthHandler can read a stored access token, add it to each request, and pass the request onward. After successful login, assign loginResult.AccessToken to AuthHandler.AuthToken so later authenticated requests contain the token. section 8.3.2

