DioRed.Aith.Client 1.0.0-preview.7

This is a prerelease version of DioRed.Aith.Client.
dotnet add package DioRed.Aith.Client --version 1.0.0-preview.7
                    
NuGet\Install-Package DioRed.Aith.Client -Version 1.0.0-preview.7
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DioRed.Aith.Client" Version="1.0.0-preview.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DioRed.Aith.Client" Version="1.0.0-preview.7" />
                    
Directory.Packages.props
<PackageReference Include="DioRed.Aith.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DioRed.Aith.Client --version 1.0.0-preview.7
                    
#r "nuget: DioRed.Aith.Client, 1.0.0-preview.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DioRed.Aith.Client@1.0.0-preview.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DioRed.Aith.Client&version=1.0.0-preview.7&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=DioRed.Aith.Client&version=1.0.0-preview.7&prerelease
                    
Install as a Cake Tool

DioRed.Aith.Client

DioRed.Aith.Client provides a strongly-typed, high-level OAuth 2.0 client for client_credentials (service-to-service) authentication against Aith from DioRED.

It handles:

  • Fetching access tokens using client_id + client_secret
  • Token caching and automatic refresh
  • Attaching Authorization: Bearer headers to outgoing requests
  • Seamless HttpClient integration via IHttpClientFactory

🚀 Installation

dotnet add package DioRed.Aith.Client

✨ Quick Start

Register an Aith-backed HttpClient:

builder.Services.AddAithClient("my-api", o =>
{
    o.Authority    = "https://auth.example.com";
    o.ClientId     = "service-a";
    o.ClientSecret = builder.Configuration["Aith: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:

  1. AithTokenClient

Retrieves and caches client_credentials tokens from:

POST {Authority}/oauth/token
grant_type=client_credentials
client_id=...
client_secret=...
scope=...
  1. AithClientCredentialsHandler

A delegating handler that:

  • obtains a fresh token when needed,
  • attaches it to each outbound request.
  1. AddAithClient(...) 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 Aith-backed HttpClients:

builder.Services.AddAithClient("service-a", ...);
builder.Services.AddAithClient("service-b", ...);

📚 Summary

Use DioRed.Aith.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:

👉 DioRed.Aith.AspNetCore (NuGet)

Product 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 was computed.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.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.7 89 5/11/2026
1.0.0-preview.6 73 4/21/2026
1.0.0-preview.5 91 12/29/2025