Table of Contents

Class EntraWorkloadTokenHandler

Namespace
NuvTools.Security.AspNetCore.Entra
Assembly
NuvTools.Security.AspNetCore.Entra.dll

The calling side of AddEntraWorkload(AuthenticationBuilder, string, Action<EntraWorkloadOptions>): puts an Entra workload token for one scope on every request.

public class EntraWorkloadTokenHandler : DelegatingHandler, IDisposable
Inheritance
EntraWorkloadTokenHandler
Implements
Inherited Members

Remarks

The credential is normally the app's managed identity (DefaultAzureCredential, selected by AZURE_CLIENT_ID). It caches the token and renews it before it expires, so asking on every request reaches Entra about once an hour. Nothing on either side holds a secret.

Constructors

EntraWorkloadTokenHandler(TokenCredential, string)

The calling side of AddEntraWorkload(AuthenticationBuilder, string, Action<EntraWorkloadOptions>): puts an Entra workload token for one scope on every request.

public EntraWorkloadTokenHandler(TokenCredential credential, string scope)

Parameters

credential TokenCredential

The identity the token is issued to.

scope string

The receiving API's scope, usually its application ID URI followed by /.default.

Remarks

The credential is normally the app's managed identity (DefaultAzureCredential, selected by AZURE_CLIENT_ID). It caches the token and renews it before it expires, so asking on every request reaches Entra about once an hour. Nothing on either side holds a secret.

Methods

SendAsync(HttpRequestMessage, CancellationToken)

Sends an HTTP request to the inner handler to send to the server as an asynchronous operation.

protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)

Parameters

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

ArgumentNullException

The request was null.

OperationCanceledException

The cancellation token was canceled. This exception is stored into the returned task.