Authaz.Sdk
0.3.4
See the version list below for details.
dotnet add package Authaz.Sdk --version 0.3.4
NuGet\Install-Package Authaz.Sdk -Version 0.3.4
<PackageReference Include="Authaz.Sdk" Version="0.3.4" />
<PackageVersion Include="Authaz.Sdk" Version="0.3.4" />
<PackageReference Include="Authaz.Sdk" />
paket add Authaz.Sdk --version 0.3.4
#r "nuget: Authaz.Sdk, 0.3.4"
#:package Authaz.Sdk@0.3.4
#addin nuget:?package=Authaz.Sdk&version=0.3.4
#tool nuget:?package=Authaz.Sdk&version=0.3.4
Authaz.Sdk
Official .NET SDK for the Authaz Management API. Authentication, authorization, and identity management for your applications.
Install
dotnet add package Authaz.Sdk
Quickstart
using Authaz.Sdk;
using Microsoft.Extensions.DependencyInjection;
var services = new ServiceCollection();
services.AddAuthazSdk(opts =>
{
opts.BaseAddress = new Uri("https://api.authaz.com");
opts.ApiKey = "your-api-key";
});
var sp = services.BuildServiceProvider();
var authaz = sp.GetRequiredService<IAuthazClient>();
// List users
var result = await authaz.Users.ListAsync();
if (result.IsSuccess)
Console.WriteLine($"Found {result.Value!.Data.Count} users");
With ASP.NET Core
builder.Services.AddAuthazSdk(opts =>
{
opts.BaseAddress = new Uri(builder.Configuration["Authaz:BaseUrl"]!);
opts.ApiKey = builder.Configuration["Authaz:ApiKey"];
});
// Inject IAuthazClient anywhere:
app.MapGet("/users", async (IAuthazClient authaz) =>
{
var result = await authaz.Users.ListAsync();
return result.IsSuccess ? Results.Ok(result.Value) : Results.Problem(result.Error!.Message);
});
Error handling
Every method returns AuthazResult<T> — a discriminated union that is either successful or a typed error. No exceptions for expected API failures.
var result = await authaz.Users.GetAsync(userId);
switch (result.Error)
{
case null:
Console.WriteLine(result.Value!.Email);
break;
case AuthazError.NotFound:
Console.WriteLine("User not found");
break;
case AuthazError.Unauthorized:
Console.WriteLine("Invalid API key");
break;
case AuthazError.Forbidden e:
Console.WriteLine($"Permission denied: {e.Message}");
break;
case AuthazError.Validation e:
foreach (var f in e.Fields)
Console.WriteLine($"{f.Field}: {f.Message}");
break;
case AuthazError.RateLimited e:
Console.WriteLine($"Rate limited — retry after {e.RetryAfter}");
break;
case AuthazError.Server e:
Console.WriteLine($"Server error {e.StatusCode}: {e.Message}");
break;
case AuthazError.Network e:
Console.WriteLine($"Network failure: {e.InnerException.Message}");
break;
case AuthazError.Canceled:
Console.WriteLine("Operation was canceled");
break;
}
Sub-clients
IAuthazClient exposes 8 top-level sub-clients:
| Property | Description |
|---|---|
Users |
List, get, suspend, activate, unlock, delete users; manage sessions and MFA |
Applications |
CRUD apps; branding, custom domains, config |
Tenants |
Multi-tenant management; per-tenant auth provider config |
Authorization |
Roles, policies (RBAC + MFA/password/session/lockout), permission checks |
Invitations |
Send and manage invitations |
Email |
Email provider config and transactional templates |
Auth |
API key management (org/app scoped + user-bound); OAuth and M2M credentials; auth flow; account recovery |
Audit |
Trail log access with cursor pagination and full-text search |
Custom credential provider
Implement IAuthazCredentialProvider for non-API-key authentication (e.g. forwarding a user's bearer token from an HTTP context):
public sealed class MyCredentialProvider(IHttpContextAccessor ctx) : IAuthazCredentialProvider
{
public ValueTask ApplyAsync(HttpRequestMessage request, CancellationToken ct)
{
var token = ctx.HttpContext?.Request.Cookies["access_token"];
if (!string.IsNullOrEmpty(token))
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
return ValueTask.CompletedTask;
}
}
// Registration:
services.AddAuthazSdk(opts => { opts.BaseAddress = ...; })
.WithCredentials<MyCredentialProvider>();
Supported frameworks
net8.0 · net9.0 · net10.0 — AOT-compatible
License
MIT
| 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
- Microsoft.Extensions.Http (>= 9.0.0)
- Microsoft.Extensions.Http.Resilience (>= 9.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
-
net8.0
- Microsoft.Extensions.Http (>= 9.0.0)
- Microsoft.Extensions.Http.Resilience (>= 9.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
-
net9.0
- Microsoft.Extensions.Http (>= 9.0.0)
- Microsoft.Extensions.Http.Resilience (>= 9.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.