Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Feature Request] Expose CorrelationId from MsalException  #4187

@KurzyukovAndrey

Description

@KurzyukovAndrey

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

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions