Skip to content

[Auth][DI] Custom and Web Authentication - Service Registration fails silently with Error when using TypedSettings? #2895

Open

Description

@DevTKSS

Current behavior

Using the AddCustom Authentication Extension of Uno, the DI Service Registration fails silently with:

08-29 18:16:31.585+02:00 D/Uno.UI.Xaml.Core.PointerCapture: Button-01BB9D65: Releasing (Any) capture of pointer Mouse/1
[18:16:31 DBG] LoginAsync - Error attempting to login [Error - No service for type 'DevTKSS.MyManufacturerERP.Infrastructure.Services.OAuthService' has been registered.]
08-29 18:16:31.587+02:00 D/Uno.Extensions.Authentication.Custom.CustomAuthenticationProvider: LoginAsync - Error attempting to login [Error - No service for type 'DevTKSS.MyManufacturerERP.Infrastructure.Services.OAuthService' has been registered.]

Full Serilog log: log.txt

when clicking on the LoginStart executing Button. (same in the repro Project if you remark the different naming.)

Since I seen that the Service Registration in the Hostbuilder normally comes after Authentication Registration, I did already set it before the Auth registration with the appropriate Interface and Implementation, so all the Authentication Extension was left to do is to pick it up and use it.
Used code for that:

 .UseConfiguration(configure: unoConfigBuilder =>
     unoConfigBuilder
        .EmbeddedSource<App>()
        .Section<AppConfig>()
        .Section<OAuthOptions>("EtsyOAuthOptions")
 )
// Register Json serializers (ISerializer and ISerializer)
.UseSerialization((context, services) => services
    .AddContentSerializer(context)
)
.UseHttp((context, services) =>
{
#if DEBUG
    // DelegatingHandler will be automatically injected
    services.AddTransient<DelegatingHandler, DebugHttpHandler>();
#endif
    services.AddRefitClientWithEndpoint<IEtsyOAuthEndpoints, OAuthOptions>(
        context: context,
        options: context.Configuration.GetSection("EtsyOAuthOptions").Get<OAuthOptions>(),
        name: "EtsyClient",
        configure: (clientBuilder, options) => clientBuilder
        .ConfigureHttpClient(httpClient =>
        {
            httpClient.BaseAddress = new Uri("https://openapi.etsy.com");
            if (options?.ClientID is null)
            {
                throw new ArgumentNullException(options?.ClientID,nameof(options.ClientID));
            }
            httpClient.DefaultRequestHeaders.Add("x-api-key", options.ClientID);
        })
    )
    .AddRefitClient<IEtsyUserEndpoints>(context);
})
.ConfigureServices((context, services) =>
{
    // TODO: Register your services
                   
    // Register our custom OAuth service as the main authentication service
    services.AddSingleton<IOAuthService,OAuthService>();
})
.UseAuthentication(authBuilder =>
authBuilder.AddCustom<OAuthService>(custom =>
{
    custom.Login(async (service, serviceProvider, dispatcher, tokenCache, tokens, ct)
        => await service.LoginAsync(serviceProvider, dispatcher, tokenCache, tokens, ct));
    custom.Refresh(async (service, serviceProvider, tokenCache, tokens, ct)
        => await service.RefreshAsync(serviceProvider, tokens, ct));
    custom.Logout(async (service, serviceProvider,dispatcher, tokenCache, tokens, ct)
        => await service.LogoutAsync(dispatcher,tokens, ct));
}, name: OAuthService.ProviderName ))

Expected behavior

  • if we do already register a Typed AND Custom Authentication Provider instead of e.g. "just" not working at runtime, even while we did already registring our Service ourselfs, the Uno Authentication Extension should be able to AT LEAST pick this up and provide it working at runtime.
  • if we missed providing the Options or may not registred our service holding the delegate, then it should throw the regular "can not resolve Service xy" like if you would use a really not fully registred Service.

If the Extension fails because I did something wront, then I would expect it to tell me a reason I can fix. but if I registred that service, that should not be a problem.

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

Start this app:
UnoApp4.zip
and just click on the login button thats executing the Login task.

(less content would be a not existing app)

Environment

here are no options to check dear team , so what do you want to know here?

Nuget Package (s):
the template provided ones?
Package Version(s):
same here
Affected platform(s):

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

Visual Studio:

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

Relevant plugins:

  • Resharper (version: )

Anything else we need to know?

tryed WebAuth before, failing on that damn WebAuthenticationBrokerProvider is not implemented, tryed OIDC extension, not working (most likly because of the WebAuth issue) and now not even Custom Auth is working? So from that, I recommend Uno to clearly state in their docs that all of the Authentication Extensions are just not usable in the latest released Version 6.2. since that service in the repro app got already reduced to no f*** logic and not even then its working?!

Activity

  1. added
    kind/bug
    triage/untriaged
    on Aug 29, 2025
  2. changed the title [-][CustomAuth][DI] Custom Authentication Provider - Service Registration fails with Error[/-] [+][CustomAuth][DI] Custom Authentication Provider - Service Registration fails silently with Error[/+] on Aug 30, 2025
  3. DevTKSS commented on Sep 15, 2025

    @DevTKSS
    ContributorAuthor

    so I will now give up on this *** extension. I did see that this fu*** service it tells would be missing, is there and the call to the AddWeb was then the next line, it does load the UI but keeps failing to resolve this Service no matter what I did.

    Hopefully the Team will care about this in the future...

  4. DevTKSS commented on Sep 15, 2025

    @DevTKSS
    ContributorAuthor

    @Jen-Uno would you please check if there is anybody who can fix the Authentication Extension ? I would like to use it but its like a mission impossible. No matter what I tryed it gave me the same error log without any future information about how I could solve it 😕
    Asked on Discord flt like about hundred times hoping for any help but gotten no step further.
    If I would at least be able to use Custom auth, I think my implementation attempt you can see in the linked issue, could maybe work, I wanted to test it, but I can not even debug step through it with this "silently failing" issue blocking it.

    I am really wondering how others have no problems with it so I guess I might be just the only one trying to use the TypedSettings -> generic overload of it 🤔 but normally that should not be a problem otherwise Uno would not have published this?
    All I am left to try is to use the non typed definition which we get provided in the template and which did navigate to the web url at least on android as I tried that.

    But as said, it makes in my opinion no sense why the other way could not work 🤷 hopefully the team can fix it or if not working, then please just remove it as option🤷

  5. changed the title [-][CustomAuth][DI] Custom Authentication Provider - Service Registration fails silently with Error[/-] [+][Auth][DI] Custom and Web Authentication - Service Registration fails silently with Error when using TypedSettings?[/+] on Sep 15, 2025
  6. DevTKSS commented on Sep 20, 2025

    @DevTKSS
    ContributorAuthor

    nope, so even without TypedSettings usage, its not able to register the Provider. Replicated exactly how the WebAuthProvider does its registration just not specifying any action, which normally should just use the Provider own defined Methods as is, but that doesnt work either.
    tryed to do this here:
    DevTKSS/DevTKSS.MyManufacturerERP@e88f22d

  7. DevTKSS commented on Nov 13, 2025

    @DevTKSS
    ContributorAuthor

    @kazo0 could you or someone else of the team maybe check why it is not possible to use the generic overload?

    Would be cool if I would not have to spam my App.xaml.cs with delegate code when I should be able to "just" use a seperate service, which also could by that have ctor parameters and configured in registration.

    The error message does not even let me know any detail of reason why thats not working, just this fail to resolve 😅
    Is there nobody using it with generic overload?
    Or is it just unrealistic that my desktop app might does have different providers registered? Even when assuming I would want to authenticate to my server project and want to allow my user to use different auth methods like fb and google and whatever else there should be a normal way to do this on my opinion 🤔

    I created a AspNet-contrib provider that I will test on their MVC app but after that I normally would have wanted to try attaching my uno client to request the asp net core project aka Server, to have it also save just like uno does with the chefs app. But that is only using again the delegate methods😬

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

    kind/bugtriage/untriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions