DioRed.Dais.Client
1.0.0-preview.4
DAIS has been completely renamed to Aith
dotnet add package DioRed.Dais.Client --version 1.0.0-preview.4
NuGet\Install-Package DioRed.Dais.Client -Version 1.0.0-preview.4
<PackageReference Include="DioRed.Dais.Client" Version="1.0.0-preview.4" />
<PackageVersion Include="DioRed.Dais.Client" Version="1.0.0-preview.4" />
<PackageReference Include="DioRed.Dais.Client" />
paket add DioRed.Dais.Client --version 1.0.0-preview.4
#r "nuget: DioRed.Dais.Client, 1.0.0-preview.4"
#:package DioRed.Dais.Client@1.0.0-preview.4
#addin nuget:?package=DioRed.Dais.Client&version=1.0.0-preview.4&prerelease
#tool nuget:?package=DioRed.Dais.Client&version=1.0.0-preview.4&prerelease
DioRed.Dais.Client
DioRed.Dais.Client provides a strongly-typed, high-level DAIS client_credentials OAuth2 client for server-to-server communication.
It handles:
- Fetching access tokens using
client_id + client_secret - Token caching and automatic refresh
- Attaching
Authorization: Bearerheaders to outgoing requests - Seamless HttpClient integration via
IHttpClientFactory
🚀 Installation
dotnet add package DioRed.Dais.Client
✨ Quick Start
Register a DAIS-backed HttpClient:
builder.Services.AddDaisClient("my-api", o =>
{
o.Authority = "https://auth.example.com";
o.ClientId = "service-a";
o.ClientSecret = builder.Configuration["Dais:ServiceA:Secret"];
o.Scopes = new[] { "my-api.read" };
});
builder.Services.AddHttpClient("my-api", client =>
{
client.BaseAddress = new Uri("https://api.example.com");
});
Use it in services:
public class ApiService
{
private readonly HttpClient _client;
public ApiService(IHttpClientFactory factory)
{
_client = factory.CreateClient("my-api");
}
public async Task<string> GetDataAsync()
{
var response = await _client.GetStringAsync("/v1/data");
return response;
}
}
All requests automatically receive:
Authorization: Bearer {access_token}
🔐 How It Works
The library implements:
DaisTokenClient
Retrieves and caches client_credentials tokens from:
POST {Authority}/oauth/token
grant_type=client_credentials
client_id=...
client_secret=...
scope=...
DaisClientCredentialsHandler
A delegating handler that:
- obtains a fresh token when needed,
- attaches it to each outbound request.
AddDaisClient(...)extension
Registers all required components with proper DI lifetimes.
⚙️ Advanced Usage
Custom scopes:
o.Scopes = new[] { "payments.write", "orders.read" };
Custom token endpoint:
o.TokenEndpoint = "https://auth.example.com/custom-token";
Multiple DAIS-backed HttpClients:
builder.Services.AddDaisClient("service-a", ...);
builder.Services.AddDaisClient("service-b", ...);
📚 Summary
Use DioRed.Dais.Client for any app-to-api or microservice-to-microservice authentication:
- backend jobs
- background services
- microservice communication
- internal admin tools
- API gateways
For interactive login in web apps (Authorization Code + PKCE), use:
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
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 | |
|---|---|---|---|
| 1.0.0-preview.4 | 149 | 11/29/2025 | |
| 1.0.0-preview.3 | 440 | 11/15/2025 | |
| 1.0.0-preview.2 | 430 | 11/2/2025 | |
| 1.0.0-preview.1 | 447 | 11/2/2025 |