Skip to content

[Auth][OIDC] Authentication doesn't seem to work on Wasm #2872

Open

Description

@abbatepabloo

Current behavior

Image

When click on button Login a NullReferenceException is thrown:

fail: Uno.UI.Dispatching.NativeDispatcher[0]
NativeDispatcher unhandled exception
System.NullReferenceException: Object reference not set to an instance of an object.
at IdentityModel.Client.AuthorizeResponse.ParseRaw()
at IdentityModel.Client.AuthorizeResponse..ctor(String raw)
at IdentityModel.OidcClient.OidcClient.ProcessResponseAsync(String data, AuthorizeState state, Parameters backChannelParameters, CancellationToken cancellationToken) in //src/OidcClient/OidcClient.cs:line 187
at IdentityModel.OidcClient.OidcClient.LoginAsync(LoginRequest request, CancellationToken cancellationToken) in /
/src/OidcClient/OidcClient.cs:line 87
at Uno.Extensions.Authentication.Oidc.OidcAuthenticationProvider.InternalLoginAsync(IDispatcher dispatcher, IDictionary2 credentials, CancellationToken cancellationToken) at Uno.Extensions.Authentication.BaseAuthenticationProvider.LoginAsync(IDispatcher dispatcher, IDictionary2 credentials, CancellationToken cancellationToken)
at Uno.Extensions.Authentication.AuthenticationService.LoginAsync(IDispatcher dispatcher, IDictionary2 credentials, String provider, Nullable1 cancellationToken)
at UnoApp1.Presentation.LoginViewModel.DoLogin() in C:\Temp\UnoApp1\UnoApp1\Presentation\LoginViewModel.cs:line 25
at CommunityToolkit.Mvvm.Input.AsyncRelayCommand.AwaitAndThrowIfFailed(Task executionTask)
at System.Threading.Tasks.Task.<>c.b__128_0(Object state)
at Uno.UI.Dispatching.NativeDispatcherSynchronizationContext.<>c__DisplayClass3_0.b__0() in C:\a\1\s\src\Uno.UI.Dispatching\Native\NativeDispatcherSynchronizationContext.cs:line 21
at Uno.UI.Dispatching.NativeDispatcher.RunAction(NativeDispatcher dispatcher, Action action) in C:\a\1\s\src\Uno.UI.Dispatching\Native\NativeDispatcher.cs:line 153

Regardless of the exception, the login windows is opened and I'm able to login into the demo's Duende Server.

Image

But when the callback is executed, the user is not recognized (not logged in)

Image

Expected behavior

The user should be logged in after providing the right credentials in the Duende Server.

How to reproduce it (as minimally and precisely as possible)

UnoApp1.zip

The attached project has been created using Uno's templates with OIDC Authentication against Duende's demo server.
After running, press the Login button and check the output window in Visual Studio to see the exception.
Verify that the user is not authenticated:
Title += $" - Is Authenticated: {authentication.IsAuthenticated()}";

Environment

Nuget Package (s):

Package Version(s):

Affected platform(s):

  • iOS
  • macOS (AppKit)
  • Mac Catalyst
  • Android
  • WebAssembly
  • Windows
  • Skia (WPF)
  • Skia (GTK on Linux/macOS/Windows)
  • Skia (Linux Framebuffer)
  • Build tasks

Visual Studio:

  • 2019 (version: )
  • 2022 (version: )
  • Visual Studio Code (version: )
  • Rider Windows (version: )
  • Rider macOS (version: )

Relevant plugins:

  • Resharper (version: )

Anything else we need to know?

Activity

  1. added
    kind/bug
    triage/untriaged
    on Jul 29, 2025
  2. DevTKSS commented on Jul 29, 2025

    @DevTKSS
    Contributor

    could the version / Rebranding be causing this? Uno is using the version before the rebranding at this release:

  3. abbatepabloo commented on Jul 29, 2025

    @abbatepabloo
    Author

    If I understood correctly from the breaking change, this assembly shouldn't be present:

    Image

    Instead Duende.IdentityModel should be referenced.
    Am I right, or am I getting lost somewhere?

  4. DevTKSS commented on Jul 30, 2025

    @DevTKSS
    Contributor

    @abbatepabloo this is what the linked PR is updating 👍 But as its a Breaking change, it can only be merged with the next major version.
    @kazo0 will maybe be able to tell you more about this or help you, isnt it?

  5. DevTKSS commented on Jul 30, 2025

    @DevTKSS
    Contributor

    how do you get to the form? I tryed on my side with a valid api and api key setup (oAuth2 no oidc) and wether on Desktop, nor Webassembly or Android, or windows does do anything...

  6. DevTKSS commented on Jul 30, 2025

    @DevTKSS
    Contributor

    breaking also on Desktop with StackOverflowException (no Details in Exception provided)
    Wasm also seems to come from Native dispatcher and Source generators?

    Output-Debug.txt

  7. kazo0 commented on Jul 31, 2025

    @kazo0
    Contributor

    @abbatepabloo / @DevTKSS thanks for the reports and the helpful attached sample apps and testing!

    Definitely something we need to investigate. I have set it to be prioritized for upcoming release iterations. I have also logged a couple issues surrounding Auth that will hopefully address some of this in terms of guidance as well as steps forward for the current reliance on IdentityModel for the OIDC Auth Extensions:

    #2875
    #2876

  8. added theissue type on Aug 6, 2025
  9. self-assigned this
    on Aug 15, 2025
  10. removed their assignment
    on Sep 23, 2025
  11. kazo0 commented on Oct 10, 2025

    @kazo0
    Contributor

    @abbatepabloo if you were to target net10 instead of net9 for the app, does it work? I believe this is the same issue as unoplatform/uno#21585

    You can try moving to targetting net10.0 and you may need to temporarily add <JsonSerializerIsReflectionEnabledByDefault>true</JsonSerializerIsReflectionEnabledByDefault> to your csproj

  12. DevTKSS commented on Oct 30, 2025

    @DevTKSS
    Contributor

    @kazo0 with which uno.sdk (dev?) version could this be re-tested after

    is stated to be merged from the PR? Not sure how to overwrite normally uno.sdk managed uno packages 🤔

  13. removed
    kind/bug
    triage/untriaged
    on Nov 25, 2025
  14. changed the title [-]OIDC Authentication doesn't seem to work on Wasm[/-] [+][Auth] OIDC Authentication doesn't seem to work on Wasm[/+] on Nov 25, 2025
  15. changed the title [-][Auth] OIDC Authentication doesn't seem to work on Wasm[/-] [+][Auth][OIDC] Authentication doesn't seem to work on Wasm[/+] on Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions