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
Version: MSAL.NET @ 4.42
Platform: Windows 11, net5.0-windows10.0.17763.0
Auth flow: Broker and Interactive Web auth (embedded web view only)
Repro @bgavrilMS - we have an easy repro internally and a current bugfix in the auth CLI.
privateclassMsalHttpClientFactoryAdaptor:IMsalHttpClientFactory{privateHttpClientinstance;publicMsalHttpClientFactoryAdaptor(HttpClientinstance){if(instance==null){thrownew ArgumentNullException(nameof(instance));}this.instance =instance;}public HttpClient GetHttpClient(){// MSAL calls this method each time it wants to use an HTTP client.// We ensure we only create a single instance to avoid socket exhaustion.returnthis.instance;}}//---verpca= PublicClientApplicationBuilder
.Create(this.clientId.ToString()).WithAuthority(this.Authority).WithBroker();vartokenSource=new CancellationStokenSource();vartimeout= TimeSpan.FromSeconds(15);
tokenSource.CancelAfter(timeout);
await pca.AcquireTokenInteractive(scopes).ExecuteAsync(tokenSource.Token);// Expect OperationCancelledException to be thrown - but the Web or broker UI hangs forever.
Expected behavior
An OperationCancelledException should be thrown by calling token.ThrowIfCancellationRequested().
Possible solution
Internally we have a workaround to run await a timer task that checks if the task is done every 100ms and after the timeout, returns a Task.FromResult<T>(null).
Additional context / logs / screenshots / links to code
We have debugged the un-cancellable call to this Task that runs with a custom Task Scheduler
I took a different approach than just killing the thread. The Form gets auto-closed when the Cancellation Token is set, and an OperationCancelledException gets thrown
Version: MSAL.NET @ 4.42
Platform: Windows 11,
net5.0-windows10.0.17763.0
Auth flow: Broker and Interactive Web auth (embedded web view only)
Repro
@bgavrilMS - we have an easy repro internally and a current bugfix in the auth CLI.
Expected behavior
An
OperationCancelledException
should be thrown by callingtoken.ThrowIfCancellationRequested()
.Possible solution
Internally we have a workaround to run await a timer task that checks if the task is done every 100ms and after the timeout, returns a
Task.FromResult<T>(null)
.Additional context / logs / screenshots / links to code
We have debugged the un-cancellable call to this Task that runs with a custom Task Scheduler
microsoft-authentication-library-for-dotnet/src/client/Microsoft.Identity.Client/Platforms/Features/WebView2WebUi/WebView2WebUi.cs
Line 74 in 96ec275
The text was updated successfully, but these errors were encountered: