Microsoft.Identity.Client.Extensibility.ConfidentialClientApplicationBuilderExtensions
Extensibility methods for ConfidentialClientApplicationBuilder
public static ConfidentialClientApplicationBuilder OnCompletion(this ConfidentialClientApplicationBuilder builder, Func<AssertionRequestOptions, ExecutionResult, Task> onCompletion)
Configures an async callback that is invoked when a token acquisition request completes.
This callback is invoked once per AcquireTokenForClient call, after all retry attempts have been exhausted.
While named OnCompletion for the common case, this callback fires for both successful and failed acquisitions.
This enables scenarios such as telemetry, logging, and custom result handling.
public static ConfidentialClientApplicationBuilder OnMsalServiceFailure(this ConfidentialClientApplicationBuilder builder, Func<AssertionRequestOptions, ExecutionResult, Task<bool>> onMsalServiceFailure)
Configures an async callback that is invoked when MSAL receives an error response from the identity provider (Security Token Service).
The callback determines whether MSAL should retry the token request or propagate the exception.
This callback is invoked after each service failure and can be called multiple times until it returns false or the request succeeds.
public static ConfidentialClientApplicationBuilder WithAppTokenProvider(this ConfidentialClientApplicationBuilder builder, Func<AppTokenProviderParameters, Task<AppTokenProviderResult>> appTokenProvider)
Allows setting a callback which returns an access token, based on the passed-in parameters.
MSAL will pass in its authentication parameters to the callback and it is expected that the callback
will construct a AppTokenProviderResult and return it to MSAL.
MSAL will cache the token response the same way it does for other authentication results.
public static ConfidentialClientApplicationBuilder WithCertificate(this ConfidentialClientApplicationBuilder builder, Func<AssertionRequestOptions, Task<X509Certificate2>> certificateProvider, CertificateOptions certificateOptions)
Configures an async callback to provide the client credential certificate dynamically.
The callback is invoked before each token acquisition request to the identity provider (including retries).
This enables scenarios such as certificate rotation and dynamic certificate selection based on application context.