AffinidiTdk.AuthProvider
1.1.1
dotnet add package AffinidiTdk.AuthProvider --version 1.1.1
NuGet\Install-Package AffinidiTdk.AuthProvider -Version 1.1.1
<PackageReference Include="AffinidiTdk.AuthProvider" Version="1.1.1" />
<PackageVersion Include="AffinidiTdk.AuthProvider" Version="1.1.1" />
<PackageReference Include="AffinidiTdk.AuthProvider" />
paket add AffinidiTdk.AuthProvider --version 1.1.1
#r "nuget: AffinidiTdk.AuthProvider, 1.1.1"
#:package AffinidiTdk.AuthProvider@1.1.1
#addin nuget:?package=AffinidiTdk.AuthProvider&version=1.1.1
#tool nuget:?package=AffinidiTdk.AuthProvider&version=1.1.1
AffinidiTdk.AuthProvider
This is a .NET TDK package which generates authorisation tokens to initialise TDK clients to access Affinidi services.
Requirements
- .NET 8 SDK (minimum version:
8.0.400) - Compatible OS: Windows, macOS, or Linux
You can check your installed version using:
dotnet --version
Features
- JWT Validation: Validate JWT tokens with a public key fetched from the API Gateway.
- Project Scoped Tokens: Fetch project-scoped tokens to interact with Affinidi services.
Installation
To use it in your project, you can install it via NuGet:
dotnet add package AffinidiTdk.AuthProvider
To get ProjectScopedToken you need to initialize AuthProvider. Please check our docs how to obtain required secrets:
Thread Safety
The AuthProvider class is thread-safe and designed for high-concurrency environments:
- Internally synchronizes token generation using a lock.
- Automatically caches tokens and refreshes only when expired.
- You can safely reuse a single AuthProvider instance across multiple threads or HTTP requests.
- No additional locking or synchronization is required.
Token Management
You can create one shared AuthProvider instance and pass its token generator to multiple API clients (e.g., Wallets, IAM):
using AffinidiTdk.AuthProvider;
AuthProvider authProvider = new AuthProvider(new AuthProviderParams
{
ProjectId = "PROJECT_ID",
TokenId = "TOKEN_ID",
PrivateKey = "PRIVATE_KEY",
KeyId = "KEY_ID", // [OPTIONAL] unless unique value used on for the PAT
Passphrase = "PASSPHRASE" // [OPTIONAL] unless private key is encrypted
});
❗️When you call:
string token = await authProvider.FetchProjectScopedTokenAsync();
- If a valid (non-expired) token is cached, it will be reused.
- If no token exists or it has expired, a new one will be fetched.
⚠️ Note: You usually don’t need to call this method directly when using TDK clients — use the hook-based pattern instead (see below).
Integrate with TDK Clients
To use the same AuthProvider across multiple clients (e.g. WalletsClient, IamClient), inject it into a shared HttpClient using TokenInjectingHandler (imported from AffinidiTdk.Common).
using AffinidiTdk.AuthProvider;
using AffinidiTdk.Common;
using AffinidiTdk.WalletsClient.Api;
using AffinidiTdk.WalletsClient.Client;
// init AuthProvider
var tokenHandler = new TokenInjectingHandler(
() => authProvider.FetchProjectScopedTokenAsync(),
new HttpClientHandler()
);
var httpClient = new HttpClient(tokenHandler);
// Share httpClient across multiple TDK clients
var walletApi = new WalletApi(httpClient, new Configuration());
See Examples and Tests
| 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 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. |
-
net8.0
- AffinidiTdk.Common (>= 1.1.1)
- jose-jwt (>= 5.2.0)
- Microsoft.AspNetCore.Authentication.OpenIdConnect (>= 7.0.1)
- Newtonsoft.Json (>= 13.0.3)
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.1.1 | 176 | 10/1/2025 |