OAuthHandler
Namespace: E2E.OAuth
public sealed class OAuthHandler : DelegatingHandler, IDisposableThe handler a subscription model’s HttpClient sends through. Per request it reads the stored credentials, refreshes them ahead of expiry, replaces any API key header with the bearer token, and lets the provider adjust the request. On a 401 it refreshes once and retries, or, with nothing to refresh, reports that the user signs in again. One refresh serves every model and every concurrent call over the same store, because vendors that rotate refresh tokens reject the second concurrent refresh.
Inheritance: object → HttpMessageHandler → DelegatingHandler
Implements: IDisposable
Constructors
Section titled “Constructors”OAuthHandler(IOAuthProvider, ICredentialStore, string?, HttpMessageHandler?)
Section titled “OAuthHandler(IOAuthProvider, ICredentialStore, string?, HttpMessageHandler?)”public OAuthHandler(IOAuthProvider provider, ICredentialStore store, string? loginHint = null, HttpMessageHandler? inner = null)Parameters
| Name | Type | Description |
|---|---|---|
provider |
IOAuthProvider | |
store |
ICredentialStore | |
loginHint |
string | |
inner |
HttpMessageHandler |
Methods
Section titled “Methods”SendAsync(HttpRequestMessage, CancellationToken)
Section titled “SendAsync(HttpRequestMessage, CancellationToken)”protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)Sends an HTTP request to the inner handler to send to the server as an asynchronous operation.
Parameters
| Name | Type | Description |
|---|---|---|
request |
HttpRequestMessage | The HTTP request message to send to the server. |
cancellationToken |
CancellationToken | A cancellation token to cancel operation. |
Returns: Task<HttpResponseMessage> — The task object representing the asynchronous operation.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The <code class=“paramref”>request</code> was <a href=“https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null">null</a>. |
| OperationCanceledException | The cancellation token was canceled. This exception is stored into the returned task. |