Skip to content

Question: Is there a way to register multiple authentication clients? #10

@Poltergeisen

Description

@Poltergeisen

We have a Microservice that is having some issues where I have multiple services trying to call AddAuth0AuthenticationClient with different clientIds.

Is there a way for this to work? To register a specific authentication client for a specific httpclient that I am trying to use? Am I missing something in the documentation?

Example:
In my Nuget package I try to configure the authentication specifically for this service:

            services.AddAuth0AuthenticationClient(opts =>
            {
                opts.ClientId = notificationsClientOptions.ClientId;
                opts.ClientSecret = notificationsClientOptions.ClientSecret;
                opts.Domain = notificationsClientOptions.Domain;
            });
            // configure Auth0 M2M for Notifications
            services
                .AddHttpClient<INotificationsClient, NotificationsClient>()
                .AddAccessToken(c => c.Audience = notificationsClientOptions?.Audience);

In another nuget package I try to configure the service for something else:

           services.AddAuth0AuthenticationClient(opts =>
           {
               opts.ClientId = settingsOptions.ClientId;
               opts.ClientSecret = settingsOptions.ClientSecret;
               opts.Domain = settingsOptions.Domain;
           });

           // configure Auth0 M2M for settings
           services
               .AddHttpClient<ISettingsClient, SettingsClient>()
               .AddAccessToken(c => c.Audience = settingsOptions?.Audience);

Am I doing this completely wrong? How can I configure both of these clients with different client ids/secrets in the same app?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions