in CredentialProvider.Microsoft/CredentialProviders/Vsts/MSAL/MsalTokenProvider.cs [110:140]
public async Task<IMsalToken> AcquireTokenWithUI(CancellationToken cancellationToken, ILogger logging)
{
var deviceFlowTimeout = EnvUtil.GetDeviceFlowTimeoutFromEnvironmentInSeconds(logging);
CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(deviceFlowTimeout));
var linkedCancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, cts.Token).Token;
var publicClient = await GetPCAAsync(useLocalHost: true).ConfigureAwait(false);
try
{
var msalBuilder = publicClient.AcquireTokenInteractive(new string[] { resource });
msalBuilder.WithPrompt(Prompt.SelectAccount);
msalBuilder.WithUseEmbeddedWebView(false);
var result = await msalBuilder.ExecuteAsync(linkedCancellationToken);
return new MsalToken(result);
}
catch (MsalServiceException e)
{
if (e.ErrorCode.Contains(MsalError.AuthenticationCanceledError))
{
return null;
}
throw;
}
finally
{
var helper = await GetMsalCacheHelperAsync();
helper?.UnregisterCache(publicClient.UserTokenCache);
}
}