Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows App won't launch browser... callback URL issue #10

Open
blmiles opened this issue Aug 31, 2023 · 2 comments
Open

Windows App won't launch browser... callback URL issue #10

blmiles opened this issue Aug 31, 2023 · 2 comments

Comments

@blmiles
Copy link

blmiles commented Aug 31, 2023

Hello,

I have followed this code precisely. Maui app, targeting Android, iOS and Windows. All .Net7, latest OS on each.

This sets the callback:

        builder.Services.AddSingleton(new Auth0Client(new()
        {
            Domain = "mycompany.auth0.com",
            ClientId = "xxxxxxxxxxxxxxxxx",
            Scope = "openid profile email",
#if WINDOWS
            RedirectUri = "http://localhost/callback"
#else
      RedirectUri = "com.mycompany.mycompany://callback"
#endif
        }));

I keep getting this error:

One or more errors occurred. (You need to declare the windows.protocol usage of the protocol/scheme "http" in your AppxManifest.xml file)'

[External Code]
    mycompany.Auth0.WebBrowserAuthenticator.InvokeAsync(IdentityModel.OidcClient.Browser.BrowserOptions, System.Threading.CancellationToken) in WebBrowserAuthenticator.cs
    [External Code]
    mycompany.Auth0.Auth0Client.LoginAsync() in Auth0Client.cs
    mycompany.MainPage..ctor.AnonymousMethod__0() in MainPage.xaml.cs

Cannot find much on editing the AppxManifest.xml file and no access to it in VS either unless I'm missing something.
Wonder if this might be a local Windows issue as I try run this on my local/dev machine.

EDIT: And in Android I get this:

One or more errors occurred. (You must subclass the WebAuthenticatorCallbackActivity and create an IntentFilter for it which matches your callbackUrl.)'

This sample I think needs to be expanded to include some of this info as there are obviously some new/additional steps missing. It is hard to keep up with the pace of change and moving technical targets, I realize that!

Thanks

@feraguiba
Copy link

Same issue when I tested on Android:

System.InvalidOperationException: You must subclass the WebAuthenticatorCallbackActivity and create an IntentFilter for it which matches your callbackUrl.
at Microsoft.Maui.Authentication.WebAuthenticatorImplementation.AuthenticateAsync(WebAuthenticatorOptions webAuthenticatorOptions) in D:\a_work\1\s\src\Essentials\src\WebAuthenticator\WebAuthenticator.android.cs:65
at MauiAuth0App.Auth0.WebBrowserAuthenticator.InvokeAsync(BrowserOptions options, CancellationToken cancellationToken) in /Users/faguirre/maui/examples/dotnet-maui-auth0-app/Auth0/WebBrowserAuthenticator.cs:12
at IdentityModel.OidcClient.AuthorizeClient.AuthorizeAsync(AuthorizeRequest request, CancellationToken cancellationToken) in //src/OidcClient/AuthorizeClient.cs:56
at IdentityModel.OidcClient.OidcClient.LoginAsync(LoginRequest request, CancellationToken cancellationToken) in /
/src/OidcClient/OidcClient.cs:75
at MauiAuth0App.Auth0.Auth0Client.LoginAsync() in /Users/faguirre/maui/examples/dotnet-maui-auth0-app/Auth0/Auth0Client.cs:37
at MauiAuth0App.MainPage.OnLoginClicked(Object sender, EventArgs e) in /Users/faguirre/maui/examples/dotnet-maui-auth0-app/MainPage.xaml.cs:34
at at System.Threading.Tasks.Task.<>c.b__128_0(Object state)
at Android.App.SyncContext.<>c__DisplayClass2_0.b__0() in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:36
at Java.Lang.Thread.RunnableImplementor.Run() in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36
at Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net7.0/android-33/mcw/Java.Lang.IRunnable.cs:84
at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V callback, IntPtr jnienv, IntPtr klazz) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:22

@feraguiba
Copy link

Found this repository (same creator) that works in Android:
https://github.com/auth0-blog/dotnet-maui-token-management

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants