For Microsoft Authentication library not showing the login user pop up window in windows forms application with .Net Framework 4.6

rahul 1 Reputation point
2022-09-21T04:55:41.897+00:00

we use windows form C# application which used the .Net Framework 4.6. For the same application uses the Microsoft Authentication library (MSAL) when we call the below API which is availabe in Microsoft.Identity.Client (ver- 4.43.2.0) reference - from this it didn't pop up the user sign in window. Once control goes there it didn't come back.

app.AcquireTokenInteractive(scopes)
.WithAuthority(Authority)
.ExecuteAsync()
.ConfigureAwait(false)
.GetAwaiter()
.GetResult();

anybody can please help us with this.
All suggestions are welcome !

Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} votes

1 answer

Sort by: Most helpful
  1. Alfredo Revilla - Upwork Top Talent | IAM SWE SWA 27,536 Reputation points Moderator
    2022-10-10T19:15:04.633+00:00

    Hello @rahul and thanks for sending your source code for review. The login user popup not being displayed was caused by the UI running into a deadlock. The latter was caused by mixing synchronous and asynchronous code. It's recommended to do Async All the Way and to Don't block but await instead.

    Let us know if you need additional assistance. If the answer was helpful, please accept it and complete the quality survey so that others can find a solution.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.