-
Notifications
You must be signed in to change notification settings - Fork 379
Closed
Description
Problem
We need to meter CorrelationId in case of acquiring a token. However, we cannot retrieve CorrelationId from MsalException.
Use case
The simplified code of usage is shown below:
public async Task<AuthenticationResult> AcquireTokenForClientAsync(
IEnumerable<string> scopes,
Action<AcquireTokenForClientParameterBuilder>? configuration,
CancellationToken cancellationToken)
{
var acquireTokenBuilder = _confidentialClientApplication.AcquireTokenForClient(scopes);
// WithCorrelationId might be called here.
configuration?.Invoke(acquireTokenBuilder);
try
{
var authenticationResult = await acquireTokenBuilder
.ExecuteAsync(cancellationToken)
.ConfigureAwait(false);
// authenticationResult exposes correlationId.
}
catch (MsalException ex)
{
// MsalException does not expose correlationId.
// Cannot use correlationId for metering.
}
}
Our consumers call WithCorrelationId using configuration parameter. Then, we acquire a token. In case of success, we can retrieve CorrelationId from AuthenticationResult.CorrelationId. But we cannot retrieve it from MsalException.
Proposal
Expose CorrelationId for all exceptions.
Additional context
Based on Exceptions in MSAL.NET, there are 4 exceptions. MsalServiceException and MsalUiRequiredException expose CorrelationId, but the rest do not.
Metadata
Metadata
Assignees
Type
Projects
Status
Done