Dot Net MAUI Blazer App loading Angular Application with MSAL authentication

Yaragalla, Yamanappa 1 Reputation point
2022-12-12T17:57:24+00:00

I tried to wrap the Angular application which has MSAL login within Dot Net MAUI blazer app to make it as Desktop application.
We need to set Redirect url for MSAL login so that response from login will be redirected to that url. In Angular case it is http://localhost:4200.
In case of MAUI, I guess there is no http server listening on any particular port because of that when we call MSAL login URL, it is opening in browser instead of opening within MAUI application.

Please let me know resolution for this.

Developer technologies .NET .NET MAUI
Microsoft Security Microsoft Entra Microsoft Entra ID
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2022-12-12T18:18:45.553+00:00

    MSAL authentication in desktop apps works via a webview. the library creates a web view and loads a custom page that redirects to the azure login. the redirect back (reply url will be custom protocol rather than a url) is caught and the token extracted from the url.

    Blazer web views can not create windows, so require help from the hosting (Maui) application. the application calls the MSAL library and passes the tokens to the Blazor app. Blazor Hybrid has an authentication provider that handles this. see:

    https://learn.microsoft.com/en-us/aspnet/core/blazor/hybrid/security/?view=aspnetcore-7.0&pivots=maui

    2 people found this answer helpful.
    0 comments No comments

Your answer

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