Authaz.Sdk is the typed .NET client for the Authaz Management API — list users, manage roles, send invitations, run authorization checks, query audit logs.
It's not a Universal Login SDK. End-user authentication in your .NET web app should still go through the standard OAuth 2.0 + PKCE flow (any OIDC library works); use Authaz.Sdk when your server needs to do management work.
AddAuthazSdk registers IAuthazClient as a singleton, wires up a named HttpClient, and adds a standard resilience handler (2 retries on 5xx, 10s per-attempt timeout, 30s total, circuit breaker). You don't need to add Polly yourself.
Every method returns AuthazResult<T>. There are no thrown exceptions for API errors (network/transport problems become AuthazError.Network).
var result = await authaz.Users.GetAsync(userId);if (result.IsSuccess){ var user = result.Value!; Console.WriteLine($"{user.Email} — {user.Status}");}else{ // Error is a discriminated union var problem = result.Error switch { AuthazError.NotFound nf => Results.NotFound(nf.Message), AuthazError.Unauthorized => Results.Unauthorized(), AuthazError.Forbidden f => Results.Forbid(), AuthazError.Validation v => Results.ValidationProblem( v.Fields.ToDictionary(f => f.Field, f => new[] { f.Message })), AuthazError.RateLimited r => Results.Problem( r.Message, statusCode: 429), AuthazError.Server s => Results.Problem( s.Message, statusCode: s.StatusCode), AuthazError.Network n => Results.Problem( "Authaz unreachable", statusCode: 503), _ => Results.Problem(result.Error!.Message), };}
Pattern-matching on AuthazError is the idiomatic way — every variant carries the data you need to act (HTTP status, retry hint, validation field list).
result.Value is also available via TryGetValue(out var value) if you prefer that style.
The default credential provider reads AuthazClientOptions.ApiKey and sends it as the X-API-Key header. Swap it out (e.g. for AWS Secrets Manager) by implementing IAuthazCredentialProvider and using the builder:
builder.Services .AddAuthazSdk(opts => opts.BaseAddress = new Uri("https://api.authaz.io")) .WithCredentials<MyVaultCredentialProvider>();