in src/Authentication/MsalIntegratedWindowsAuthTokenProvider.cs [31:58]
public async Task<AuthenticationResult?> GetTokenAsync(TokenRequest tokenRequest, CancellationToken cancellationToken = default)
{
try
{
string? upn = WindowsIntegratedAuth.GetUserPrincipalName();
if (upn == null)
{
logger.LogTrace(Resources.MsalUserPrincipalNameError, Marshal.GetLastWin32Error());
return null;
}
var result = await app.AcquireTokenByIntegratedWindowsAuth(MsalConstants.AzureDevOpsScopes)
.WithUsername(upn)
.ExecuteAsync(cancellationToken);
return result;
}
catch (MsalClientException ex) when (ex.ErrorCode is MsalError.WsTrustEndpointNotFoundInMetadataDocument or MsalError.IntegratedWindowsAuthNotSupportedForManagedUser)
{
logger.LogTrace(ex.Message);
return null;
}
catch (MsalUiRequiredException ex)
{
logger.LogTrace(ex.Message);
return null;
}
}