Duende.Labs.IdentityModel.DependencyInjection
2026.806.21
Prefix Reserved
dotnet add package Duende.Labs.IdentityModel.DependencyInjection --version 2026.806.21
NuGet\Install-Package Duende.Labs.IdentityModel.DependencyInjection -Version 2026.806.21
<PackageReference Include="Duende.Labs.IdentityModel.DependencyInjection" Version="2026.806.21" />
<PackageVersion Include="Duende.Labs.IdentityModel.DependencyInjection" Version="2026.806.21" />
<PackageReference Include="Duende.Labs.IdentityModel.DependencyInjection" />
paket add Duende.Labs.IdentityModel.DependencyInjection --version 2026.806.21
#r "nuget: Duende.Labs.IdentityModel.DependencyInjection, 2026.806.21"
#:package Duende.Labs.IdentityModel.DependencyInjection@2026.806.21
#addin nuget:?package=Duende.Labs.IdentityModel.DependencyInjection&version=2026.806.21
#tool nuget:?package=Duende.Labs.IdentityModel.DependencyInjection&version=2026.806.21
IdentityModel dependency injection for .NET
Dependency injection and IHttpClientFactory integration for
Duende.Labs.IdentityModel.
Installation
dotnet add package Duende.Labs.IdentityModel.DependencyInjection
Note This package is experimental/preview.
What it does
Duende.Labs.IdentityModel is a dependency-free set of HttpClient extensions. Every request
carries its own endpoint address and client credential. In an application those values are fixed
per authority, so this package lets you configure them once:
services.AddIdentityModelClient(options =>
{
options.Authority = new Uri("https://demo.duendesoftware.com");
options.ClientCredential = new ClientCredential("m2m", "secret");
options.Scope = "api";
});
public class Worker(IdentityModelClient client)
{
public async Task RunAsync(CancellationToken ct)
{
var result = await client.RequestClientCredentialsTokenAsync(ct);
}
}
Endpoints are resolved from the authority's discovery document, which is fetched once and reused
for DiscoveryRefreshInterval (24 hours by default). Failed retrievals are never cached. If the
authority or discovery policy changes, for example through a configuration reload, the cached
document is discarded and re-fetched rather than served until the interval lapses.
Named clients
services.AddIdentityModelClient("customers", options => { /* ... */ });
services.AddIdentityModelClient("partners", options => { /* ... */ });
Resolve them with keyed services:
public class Worker([FromKeyedServices("customers")] IdentityModelClient client);
Adjusting individual requests
Each method takes an optional delegate that receives the request built from your configuration:
var result = await client.RequestClientCredentialsTokenAsync(
ct,
request => request with { Scope = "api.read" });
Composing handlers
Registration returns the IHttpClientBuilder for the backing client, so caching, resilience and
telemetry compose as usual — and apply to discovery too:
services
.AddIdentityModelClient(options => { /* ... */ })
.AddHttpMessageHandler<MyHandler>()
.AddStandardResilienceHandler();
Configuration binding
services.AddIdentityModelClient(builder.Configuration.GetSection("IdentityProvider"));
Recognised keys are Authority, ClientId, ClientSecret, ClientCredentialStyle, Scope,
DiscoveryRefreshInterval, and the endpoint overrides. Relative endpoint overrides are resolved
against Authority. Values are read explicitly rather than through reflection-based binding, so
the package stays trim and AOT compatible.
Testing
There are no interfaces to mock. IdentityModelClient is a sealed concrete type; substitute an
HttpMessageHandler instead:
services
.AddIdentityModelClient(options => { /* ... */ })
.ConfigurePrimaryHttpMessageHandler(() => new FakeHandler());
Scope
This package stops at endpoint resolution and configured defaults. Token caching, automatic refresh and DPoP nonce handling belong to Duende.AccessTokenManagement.
License
IdentityModel is open source under the Apache 2.0 license.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Duende.Labs.IdentityModel (>= 2026.806.21)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Http (>= 10.0.9)
- Microsoft.Extensions.Options (>= 10.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2026.806.21 | 92 | 8/6/2026 |
| 2026.804.20 | 95 | 8/4/2026 |
| 2026.729.19 | 108 | 7/29/2026 |