jspuij/TwokaB

Question: BlazorWebView and ApiAuthorization

njannink opened this issue · 5 comments

I'm looking if BlazorWebView is a possible path to display a blazor wasm app inside a Wpf application. My blazor wasm app runs fine inside the browser, but we want to provide integration inside an existing Wpf application by showing this blazor app inside a dockable window. At the moment I use an embedded browser (FireFox / GeckoFX) control, but the BlazorWebView way looks a better solution to me.

If I try to start the blazor app I get exceptions from the Microsoft.AspNetCore.Components.WebAssembly.Authentication Api authorization components because it tries to connect to a non http(s) scheme.

Any idea if it is possible to get this to work?

The WebAssembly solution unfortunately relies on a return URL that will be redirected to. Since the webview does not have a webserver built in, the http handler will need to catch the redirect. Unfortunately the http/app scheme is not the same on every platform and on some platforms the http handler cannot catch redirects. So although technically you might be able to get it to work, I would advise against it. It's too much work, and it's brittle.

However, I've had good success with writing a custom AuthenticationStateProvider and using the default MSAL components for mobile apps in .net. There is more info in this issue:

#11

and there is some sample code here:

https://gist.github.com/jspuij/b03a4d9bff94a12aef3c7ec0b063d140

Looks good. I watched yesterday the presentation from Daniel Roth on the BlazorDay and there he also talked about the BlazorWebView. Is that the same component as this project, or did Microsoft create their own version?

See https://www.youtube.com/watch?v=XoizucRjxgU&feature=youtu.be at around 40 mins inside this presentation

I watched the presentation and i think they did their own.

They probably will do their own. Note that this project is just a fork of Steve Sanderson's WebWindow project that is able to create a window on Windows / macOS / Linux and run blazor on a native framework inside.

There is also the Mobile bindings project, which runs blazor inside a webview on mobile and uses native UI components instead of HTML.

None of them did what I want, which is use HTML, and be able to run an application on desktop AND mobile natively. I'm sure eventually they will make my project obsolete, which is fine, but I needed mobile support with HTML sooner and I didn't like the webserver / server side blazor approach that BlazorMobile takes.

i still like this project because i wanted to be able to use html in native apps now.