You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Success callback that receives the result of token acquisition attempts (typically successful, but can include failures after retries are exhausted).
/// An async callback that determines whether to retry after a service failure.
84
+
/// Receives the assertion request options and the <see cref="MsalServiceException"/> that occurred.
85
+
/// Returns <c>true</c> to retry the request, or <c>false</c> to stop retrying and propagate the exception.
86
+
/// The callback will be invoked repeatedly after each service failure until it returns <c>false</c> or the request succeeds.
87
+
/// </param>
88
+
/// <returns>The builder to chain additional configuration calls.</returns>
89
+
/// <exception cref="ArgumentNullException">Thrown when <paramref name="onMsalServiceFailure"/> is null.</exception>
90
+
/// <remarks>
91
+
/// <para>This callback is ONLY triggered for <see cref="MsalServiceException"/> - errors returned by the identity provider (e.g., HTTP 500, 503, throttling).</para>
92
+
/// <para>This callback is NOT triggered for client-side errors (<see cref="MsalClientException"/>) or network failures handled internally by MSAL.</para>
93
+
/// <para>This callback is only invoked for network token acquisition attempts, not when tokens are retrieved from cache.</para>
94
+
/// <para>When the callback returns <c>true</c>, MSAL will invoke the certificate provider (if configured via <see cref="WithCertificate"/>)
95
+
/// before making another token request, enabling certificate rotation scenarios.</para>
96
+
/// <para>MSAL's internal throttling and retry mechanisms will still apply, including respecting Retry-After headers from the identity provider.</para>
97
+
/// <para>To prevent infinite loops, ensure your callback has appropriate termination conditions (e.g., max retry count, timeout).</para>
98
+
/// <para>The callback can perform async operations such as logging to remote services, checking external health endpoints, or querying configuration stores.</para>
99
+
/// </remarks>
100
+
/// <example>
101
+
/// <code>
102
+
/// int retryCount = 0;
103
+
/// var app = ConfidentialClientApplicationBuilder
/// An async callback that receives the assertion request options and the execution result.
137
+
/// The result contains either the successful <see cref="AuthenticationResult"/> or the <see cref="MsalException"/> that occurred.
138
+
/// This callback is invoked after all retries have been exhausted (if an <see cref="OnMsalServiceFailure"/> handler is configured).
139
+
/// </param>
140
+
/// <returns>The builder to chain additional configuration calls.</returns>
141
+
/// <exception cref="ArgumentNullException">Thrown when <paramref name="onCompletion"/> is null.</exception>
142
+
/// <remarks>
143
+
/// <para>This callback is invoked for both successful and failed token acquisitions. Check <see cref="ExecutionResult.Successful"/> to determine the outcome.</para>
144
+
/// <para>This callback is only invoked for network token acquisition attempts, not when tokens are retrieved from cache.</para>
145
+
/// <para>If multiple calls to <c>OnCompletion</c> are made, only the last configured callback will be used.</para>
146
+
/// <para>Exceptions thrown by this callback will be caught and logged internally to prevent disruption of the authentication flow.</para>
147
+
/// <para>The callback is invoked on the same thread/context as the token acquisition request.</para>
148
+
/// <para>The callback can perform async operations such as sending telemetry to Application Insights, persisting logs to databases, or triggering webhooks.</para>
149
+
/// </remarks>
150
+
/// <example>
151
+
/// <code>
152
+
/// var app = ConfidentialClientApplicationBuilder
153
+
/// .Create(clientId)
154
+
/// .WithCertificate(certificate)
155
+
/// .OnCompletion(async (options, result) =>
156
+
/// {
157
+
/// if (result.Successful)
158
+
/// {
159
+
/// await telemetry.TrackEventAsync("TokenAcquired", new { ClientId = options.ClientID });
0 commit comments