Blazorade / Blazorade-MSAL

A Blazor component library that makes it easy to use authentication in your application through MSAL, both in Blazor Server and Blazor WebAssembly applications.
MIT License
17 stars 5 forks source link

Support for Blazor WASM Running in MAUI with Desktop Deployment (Win RT) #14

Open PaulSorauer-IPG opened 3 years ago

PaulSorauer-IPG commented 3 years ago

Hi @MikaBerglund

Great work on this library - it is easier to use, thanks.

I'm having an issue getting it to work for my use case however. As you might have guessed from the title, I'm running a MAUI App (Preview 7) which is using the Blazor project type (as opposed to XAML).

Your project looked like a Godsend, as Microsoft.Identity.Client is currently unsupported in Desktop deployments / WinUI versions of MAUI so I couldn't implement the 'standard' MSAL.NET approach.

I've tried a number of things to get Blazorade.MSAL working with no success. Firstly, I tried using o.InteractiveLoginMode = Blazorade.Msal.Configuration.InteractiveLoginMode.Redirect but for some reason the call to await MsalService.AcquireTokenAsync(fallbackToDefaultLoginHint: true) doesn't actually await but code execution continues despite the login window being displayed in the app.

I've then tried using InteractiveLoginMode.Popup and that does appear to await properly, however the app never appears to recognise the redirect URL, so it never captures the token and eventually throws a 'timed out' exception.

As per my set up for the same app deployed to Android, I tried using $"msal{settings.AppRegistrationClientId}://auth" as the redirect URL (which works fine in Android), and when that didn't work, I tried a bunch of others:

image

Any ideas on what might be going on and how to workaround it?

Cheers,

Paul.

MikaBerglund commented 3 years ago

Thanks for letting me know. I'll have to dig a bit into this, because, unfortunately I have not been working with MAUI applications that much yet.

But, it seems like this might be a bug with Blazorade MSAL, or if it's not a bug, then it should be a feature in Blazorade MSAL so that you could use the library also with MAUI applications.

PaulSorauer-IPG commented 3 years ago

Thanks @MikaBerglund - will wait till you've had some time to look into it. Not a big issue for me right now.

Cheers

PaulSorauer-IPG commented 3 years ago

Oh, and if you do want to look into supporting MAUI apps then I have a couple of idiosyncrasies with iOS / Android that I should point out so you can build in the proper support. Let me know if / when that might help.

MikaBerglund commented 3 years ago

Thanks!

You can link them here under this issue.