[Bug] Maui Essentials WebAuthenticator not working in WinUI
See original GitHub issueI’m attempting to use WebAuthenticator in Maui Essentials to authenticate a WinUI project, but it’s having an issue finding the manifest file. It throws an exception saying:
Could not find file ‘C:\WINDOWS\system32\AppxManifest.xml’.
If I add a local version of https://github.com/dotnet/maui/blob/main/src/Essentials/src/WebAuthenticator/WebAuthenticator.uwp.cs into my project (I made PlatformAuthenticateAsync public to test it and just passed the url and callbackUrl in the WebAuthenticatorOptions) and adjust line 51 to:
var doc = XDocument.Load($"{AppDomain.CurrentDomain.BaseDirectory}AppxManifest.xml", LoadOptions.None);
It then finds the file, however, a new error is thrown that says:
System.Runtime.InteropServices.COMException: ‘There are no remote procedure calls active on this thread. (0x800706BD)’
Additionally, I set the CallbackUrl to:
new Uri("io.identitymodel.native://callback")
and the Url to:
new Uri("https://demo.identityserver.io")
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:27 (9 by maintainers)
@jayveedee I was able to fix that error by setting
Exported = true
in the Activity class. You get this information if you see the build logs after setting it to more verbose from the VS settings.My final Activity was like this:-
Here’s one implementation that can probably be more or less lifted as is into MAUI: https://github.com/dotMorten/WinUIEx/blob/main/src/WinUIEx/WebAuthenticator.cs You might want to change the use of the module initializer and instead do it on app launch constructor