Language

ManagedIdentityApplicationBuilderExtensions.OnBackgroundTokenRefreshCompleted Method

Definition

Configures an async callback invoked when a fire-and-forget background (proactive) token refresh completes. Proactive refresh runs on a background thread after the caller has already received a valid cached token, so its outcome (latency, failures) is otherwise unobservable. This callback surfaces it, e.g. for telemetry.

public static Microsoft.Identity.Client.ManagedIdentityApplicationBuilder OnBackgroundTokenRefreshCompleted(this Microsoft.Identity.Client.ManagedIdentityApplicationBuilder builder, Func<Microsoft.Identity.Client.Extensibility.ExecutionResult,System.Threading.Tasks.Task> onBackgroundTokenRefreshCompleted);
static member OnBackgroundTokenRefreshCompleted : Microsoft.Identity.Client.ManagedIdentityApplicationBuilder * Func<Microsoft.Identity.Client.Extensibility.ExecutionResult, System.Threading.Tasks.Task> -> Microsoft.Identity.Client.ManagedIdentityApplicationBuilder
<Extension()>
Public Function OnBackgroundTokenRefreshCompleted (builder As ManagedIdentityApplicationBuilder, onBackgroundTokenRefreshCompleted As Func(Of ExecutionResult, Task)) As ManagedIdentityApplicationBuilder

Parameters

builder
ManagedIdentityApplicationBuilder

The managed identity application builder.

onBackgroundTokenRefreshCompleted
Func<ExecutionResult,Task>

An async callback that receives the ExecutionResult of the background refresh. On success, Result holds the refreshed token; on failure, Exception holds the exception, whose AuthenticationResultMetadata carries the failed attempt's HTTP duration.

Returns

The builder to chain additional configuration calls.

Exceptions

Thrown when onBackgroundTokenRefreshCompleted is null.

Remarks

Invoked on a background thread. Check Successful to determine the outcome.

Exceptions thrown by this callback are caught and logged internally so they cannot disrupt the refresh.

Applies to