Path: redb-identity/src/redb.Identity.Client/Backchannel/BackchannelServiceCollectionExtensions.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Client/Backchannel/BackchannelServiceCollectionExtensions.cs ---- using System.Net.Http.Headers; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; namespace redb.Identity.Client.Backchannel; /// /// DI extensions for the W6-0 backchannel client. Registers /// as a typed HttpClient backed by a /// dedicated using client_credentials. /// public static class BackchannelServiceCollectionExtensions { internal const string AuthorityOption = "BackchannelIdentityClientOptions.Authority"; /// /// Register the W6-0 backchannel client (). /// Coexists with the regular user-context IIdentityClient registration; the /// two clients use separate instances and separate /// Authorization header pipelines. /// public static IServiceCollection AddBackchannelIdentityClient( this IServiceCollection services, Action configure) { services.AddOptions() .Configure(configure) .Validate(o => o.Authority is { IsAbsoluteUri: true }, AuthorityDiscovery.MissingAuthorityMessage(AuthorityOption)) .ValidateOnStart(); // Token-acquisition HttpClient (no auth header): discovery and the token endpoint are absolute addresses // taken from BackchannelIdentityClientOptions.Authority, not from BaseUrl. services.AddHttpClient((sp, http) => { var o = sp.GetRequiredService>().Value; http.Timeout = o.Timeout; }); services.AddTransient(); services.AddHttpClient((sp, http) => { var o = sp.GetRequiredService>().Value; http.BaseAddress = o.BaseUrl; http.Timeout = o.Timeout; http.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); }) .AddHttpMessageHandler(); return services; } }