question

OPercyL-4597 avatar image
0 Votes"
OPercyL-4597 asked sikumars commented

Azure AD authentication for native apps

We are trying to authenticate against Azure AD in a native desktop application, and are looking for some sort of solution to authenticate in a pop-out browser, and then return to the native app and proceed as an authenticated user. Google offers a solution like this that we have used before.

Does something like this exist?

azure-ad-libraries
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@OPercyL-4597 ,

I just wanted to check in and see if you had any other questions or if you were able to resolve this issue? If you have any other questions, please let us know. Thank you for your time and patience throughout this issue.


Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.

0 Votes 0 ·

1 Answer

amanpreetsingh-msft avatar image
0 Votes"
amanpreetsingh-msft answered amanpreetsingh-msft commented

Hi @OPercyL-4597 • Thank you for reaching out.

In order to configure native desktop application for Azure AD authentication, you need to use MSAL and configure the application to acquire token interactively as shown below:

 authResult = await App.PublicClientApp.AcquireTokenInteractive(_scopes)
                                       .ExecuteAsync();

This forces users to interact with the Microsoft identity platform through a pop-up window to validate their credentials, in below scenarios:

  1. The first time users sign in to the application

  2. When users may need to reenter their credentials because the password has expired

  3. When your application is requesting access to a resource that the user needs to consent to

  4. When two factor authentication is required

For subsequent authentications, you can configure the application to acquire token silently, as mentioned below:

 var accounts = await App.PublicClientApp.GetAccountsAsync();
 var firstAccount = accounts.FirstOrDefault();
 authResult = await App.PublicClientApp.AcquireTokenSilent(scopes, firstAccount)
                                       .ExecuteAsync();

Read more: https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-v2-windows-desktop


Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @OPercyL-4597 • Just checking if the above response helped. Don't forget to "Accept the answer" if the information helped you.

0 Votes 0 ·