I have a Windows Desktop WPF application that is using the MSAL libraries to authorize a user against Azure Active Directory. It is all working, except the prompt where the user selects their account sometimes ends up behind the application (I assume when a user selects a different application in the taskbar prior completing the MSAL prompt).
I have added the WithParentActivityOrWindow option and pointed it to the main window of the application, but that doesn't attach the prompt to anything or force it in front of the application.
Is is possible to do one of the following, and if so, how?
- Force the prompt to receive focus whenever the application is the 'active' Windows application
- Embed the prompt within a WPF UserControl
For reference, the example code here is almost identical to what I'm using: https://docs.microsoft.com/en-us/azure/active-directory/develop/scenario-desktop-acquire-token-interactive?tabs=dotnet
Edit: I noticed today that Visual Studio blocks until the OAuth prompt is completed, but I'm not sure how this is accomplished or if Visual Studio is using the MSAL libraries at all.
CodePudding user response:
As the documentation states, AcquireTokenInteractive should be ran on the UI thread. My application is embedded within another application, so once I changed the call to run on the main application's UI thread it started working as expected.