microsoft / WindowsAppSDK

The Windows App SDK empowers all Windows desktop apps with modern Windows UI, APIs, and platform features, including back-compat support, shipped via NuGet.
https://docs.microsoft.com/windows/apps/windows-app-sdk/
MIT License
3.84k stars 320 forks source link

WebAuthenticationBroker API that supports all WinAppSDK OS's and application types #441

Open BenJKuhn opened 3 years ago

BenJKuhn commented 3 years ago

Proposal: Lifted WebAuthenticationBroker API that supports all Reunion OS's and application types

See #398, #366 - This issue is similar, but distinct in that it covers creating a new, lifted API, rather than updating the existing one to work for more application types.

Summary

Create an API that developers can use in any application type to implement OAuth2 functionality in any app supported by Reunion.

Rationale

The existing OS API that provides this functionality requires a core Window, which, for practical purposes, means that it only works for UWP-style application, and can't be used in other types of applications. Even if the OS API were updated, it would likely only be updated for new OS versions. It would be helpful for developers to have consistent support across OS versions.

https://task.ms/31649739

jbt00000 commented 11 months ago

This issue is over 2.5 years old. Is there any reason why the assignee @ujjwalchadha has not commented on this?

solomonfried commented 9 months ago

Do we know if anyone on the MAUI team is monitoring this issue? This is a critical block for migrating to MAUI. My Xamarin app that uses WebAuthenticator, already is blocked by Facebook and Apple on UWP from connecting due to its use of IE11. Hard to understand why this is not begin given the highest priority since most serious apps require Authentication.

Between this issue and the inability to publish MAUI UWP apps that reference a MAUI class library (https://github.com/dotnet/maui/issues/8304), it feels that UWP support for MAUI is being de-prioritized. Wondering if I should drop the platform and only support Android and iOS.

dotMorten commented 9 months ago

Last thing we were told (during community standup I believe), was that it isn't planned for v1.5.

RobinS-S commented 8 months ago

Can we get some attention on this issue? The problem has existed for quite some time now and prevents simple things such as authentication from working in MAUI for Windows. And I can't imagine MAUI is the only one that uses this.

It's unbelievable how Microsoft is trying to push for a new standard for cross-platform application development but can't manage to make their own OS work with it.

vukasinpetrovic commented 4 months ago

Is there any other way to implement social logins in MAUI besides using web authenticator? I tried it today and on windows it throws an exception without an actual exception message. I only want to develop desktop app for windows and mac, no mobile needed and I'm scrathing my head over this.

blazor.webview.js:1  
   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|39_0(Int32 hr)
   at ABI.Windows.Security.Authentication.Web.IWebAuthenticationBrokerStaticsMethods.AuthenticateAsync(IObjectReference _obj, WebAuthenticationOptions options, Uri requestUri, Uri callbackUri)
   at Windows.Security.Authentication.Web.WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions options, Uri requestUri, Uri callbackUri)
   at Microsoft.Maui.Authentication.WebAuthenticatorImplementation.AuthenticateAsync(WebAuthenticatorOptions webAuthenticatorOptions)
   at MauiHybrid.Components.Pages.Home.Authenticate()
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
ThreeSevenths commented 4 months ago

Is there any other way to implement social logins in MAUI besides using web authenticator? I tried it today and on windows it throws an exception without an actual exception message. I only want to develop desktop app for windows and mac, no mobile needed and I'm scrathing my head over this.

blazor.webview.js:1  
   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|39_0(Int32 hr)
   at ABI.Windows.Security.Authentication.Web.IWebAuthenticationBrokerStaticsMethods.AuthenticateAsync(IObjectReference _obj, WebAuthenticationOptions options, Uri requestUri, Uri callbackUri)
   at Windows.Security.Authentication.Web.WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions options, Uri requestUri, Uri callbackUri)
   at Microsoft.Maui.Authentication.WebAuthenticatorImplementation.AuthenticateAsync(WebAuthenticatorOptions webAuthenticatorOptions)
   at MauiHybrid.Components.Pages.Home.Authenticate()
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

Are you able to implement a protocol handler or run a web server on a port, and do your login via the user's browser? This seems to be the way some apps handle the login problem.

Login in App -> Start web server [optional] -> Open browser to login - > User logs in via browser -> callback url is either https://localhost:10234/login_callback or myawesomeapp://login_callback which gets the token back to you and completes the process.

dotMorten commented 4 months ago

@vukasinpetrovic see https://dotmorten.github.io/WinUIEx/concepts/Maui.html#use-winuiexs-webauthenticator-instead-of-net-mauis

solomonfried commented 4 months ago

Thank you @dotMorten I will try this.

But the question is, if there is a solution why Microsoft can't build it into WebAuthenticator. You would think that they would want to support their own platform! Authenticating users is essential to most serious applications.

dotMorten commented 4 months ago

@solomonfried Preaching to the choir. I've done my fair share of pushing for this, all the way to the point where I had meetings with the team that promised would look into doing this and explaining the reasonings why it is important, but I haven't seen any progress yet. I'm just as puzzled as you, but they are well aware of the limitation at this point, but I don't know what is keeping the priority of this back - I can't really make sense of it.

On the other hand I have no clue why .NET MAUI has left the old UWP implementation in place for MAUI when it doesn't work outside UWP, rather than just deleting all that code and throwing a more helpful PlatformNotSupported exception. Perhaps @pureween can answer that.

I created a PR to at least remove the code from MAUI and throw a more helpful error that directs you here.

vukasinpetrovic commented 3 months ago

@ThreeSevenths Thank you for the info. That seems to be the way of doing it on the desktop apps, which was my main question as to why is web authenticator used (I'm new to desktop development).

@dotMorten And of course, big thank you for your amazin library and fix for web authenticator! I tried it and it works as expected.

mominshaikhdevs commented 3 months ago

@BenJKuhn @codendone this is a crucial API. whats the latest update on this?

solomonfried commented 2 months ago

Does anyone know if WebAuthenticator will finally be supported in .NET 9? Is there an alternative MAUI solution for OAuth? Is there a 3rd party NuGet package? What are all of you doing to manage this?

I am stuck supporting my app on Xamarin because I can't implement a 3rd party login on Windows.

dotMorten commented 2 months ago

It's on the 1.7 roadmap. Did you look at WinUIEx's solution?

michael-hawker commented 2 months ago

🦙 See 1.7 Plans Discussion which calls this out here: https://github.com/microsoft/WindowsAppSDK/discussions/4710

solomonfried commented 2 months ago

@michael-hawker, @dotMorten Thanks for the update. I guess I'll have to wait till 1.7 is released. Any estimate on a date?