question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Maui Essentials WebAuthenticator not working in WinUI

See original GitHub issue

I’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:closed
  • Created 2 years ago
  • Reactions:7
  • Comments:27 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
shv07commented, May 8, 2022

@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:-

// MainActivity.cs
[Activity(NoHistory = true, LaunchMode = LaunchMode.SingleTop, Exported = true)] 
[IntentFilter(new[] { Android.Content.Intent.ActionView },
        Categories = new[] { Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable },
        DataScheme = "myapp")]
public class WebAuthenticationCallbackActivity : WebAuthenticatorCallbackActivity
 {
 }
2reactions
dotMortencommented, May 3, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Web Authenticator - .NET MAUI
Learn how a .NET MAUI app running in the Android emulator or iOS simulator can consume a ASP.NET Core web service running locally....
Read more >
MAUI WebAuthenticator Windows System.Runtime. ...
I am using MAUI blazor and making use of WebAuthenticator, it works fine for iOS and Android but not when running as Windows...
Read more >
NET MAUI Essentials Authenticator error in UWP missing ...
i'm trying to implement authentication with Essentials API in a .NET MAUI project async Task OnAuthenticate(string scheme) { try ...
Read more >
Recently Active 'maui' Questions - Page 99
I am trying to consume B2C user flow authentification with Web Authenticator (from essentials package Xamarin.forms or MAUI). Web-authenticator I am unable ...
Read more >
Microsoft Replaces Xamarin Toolkits with New .NET MAUI ...
As Xamarin.Forms morphs into the new .NET MAUI offering, Microsoft is replacing Xamarin toolkits with .NET MAUI alternatives.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found