Authlink.Portal.Client.Http
3.0.1
See the version list below for details.
dotnet add package Authlink.Portal.Client.Http --version 3.0.1
NuGet\Install-Package Authlink.Portal.Client.Http -Version 3.0.1
<PackageReference Include="Authlink.Portal.Client.Http" Version="3.0.1" />
<PackageVersion Include="Authlink.Portal.Client.Http" Version="3.0.1" />
<PackageReference Include="Authlink.Portal.Client.Http" />
paket add Authlink.Portal.Client.Http --version 3.0.1
#r "nuget: Authlink.Portal.Client.Http, 3.0.1"
#:package Authlink.Portal.Client.Http@3.0.1
#addin nuget:?package=Authlink.Portal.Client.Http&version=3.0.1
#tool nuget:?package=Authlink.Portal.Client.Http&version=3.0.1
Package Overview
Authlink.Portal.Client.Http provides a ready-to-use, production-grade implementation of the IPortalClient abstraction defined in Authlink.Portal.Client.Core.
Install
dotnet add package Authlink.Portal.Client.Http
Or via Package Manager:
PM> Install-Package Authlink.Portal.Client.Http
What's New in v3.0.0
The client now targets Authlink.Portal.Api — the new ASP.NET Core Portal API —
instead of the legacy ServiceStack Portal. Every method calls REST controller routes,
payloads are camelCase, and errors are parsed from RFC 7807 ProblemDetails.
Full Portal API coverage — ~165 new methods extend IPortalClient to every
Portal API area (OIDC scopes/claims, tenants, signing keys, activity log, metrics,
decision audit, authentication policies/providers, user administration and user
groups, client registrations, webhooks, and the remaining client/policy/resource
sub-resources), so the portal can be administered end-to-end through the SDK.
- Breaking — server pairing: 3.0.0 requires
Authlink.Portal.Apiand does not work against the legacy Portal. PointBaseUrlat the new API host:
builder.Services.AddPortalHttpClient(options =>
{
options.BaseUrl = "https://ui.portal.authlink.co.za"; // was https://portal.authlink.co.za
options.AccessToken = configuration["Authlink:Portal:AccessToken"];
});
- Breaking — REST routes and verbs across all 14 areas (users, agents,
confidential clients, API resources and groups, access-control reads, effective
permissions, invitation codes, registration links/batches/sessions, provisioning).
Creates return
201with a body; updates, deletes and lifecycle operations return204 No Contentand the client constructs the empty response types for you. - Breaking — type changes:
UpdateUserRequestdrops the deprecatedEmail/PhoneNumberproperties,UpdateAgentRequestgains required agent-governance fields, andGetAgentResponsewraps the agent in anAgentproperty of the newAgentDto. - RFC 7807 errors: the ProblemDetails
titlebecomes the errorDescription, withdetailavailable asProblemDetailmetadata.
See MIGRATION.md for the complete v2 → v3 route map and migration
steps. Consumers still on the legacy Portal should stay on the 2.x line
(maintained on the release/2.x branch).
What's New in v2.34.0
Built-in client-credentials authentication — configure ClientCredentials instead of a raw AccessToken and the SDK acquires, caches and refreshes portal tokens itself (see Authenticate your automation client):
services.AddPortalHttpClient(options =>
{
options.BaseUrl = "https://ui.portal.authlink.co.za";
options.ClientCredentials = new ClientCredentialsOptions
{
TokenEndpoint = "https://identity.authlink.co.za/api/connect/token",
ClientId = configuration["Portal:ClientId"]!,
ClientSecret = configuration["Portal:ClientSecret"]!
};
});
Public client management — the full public client surface from Authlink.Portal.Client.Core 2.34.0 is now implemented, so an SPA client can be provisioned end-to-end from a script or pipeline:
// Create the client, configure its URLs, assign a scope, link a user — all through the SDK.
var created = await _client.CreatePublicClientAsync(new CreatePublicClientRequest
{
Name = "My SPA",
Description = "Customer-facing single page app",
BaseUrl = "https://spa.example.com"
});
await _client.AddPublicClientCallbackUrlAsync(new AddPublicClientCallbackUrlRequest
{
PublicClientId = created.Value.PublicClientId,
CallbackUrl = "https://spa.example.com/callback"
});
await _client.AddPublicClientScopeAsync(new AddPublicClientScopeRequest
{
PublicClientId = created.Value.PublicClientId,
ScopeId = openIdScopeId
});
Covers CRUD, activation lifecycle, callback/origin/logout URLs, response modes, scopes (single, list and paged reads) and public keys (RSA or EC JWKs for asymmetric client authentication), with the same ErrorOr error mapping as the confidential-client surface.
What's New in v2.26.0
Declarative permission provisioning — converge your service's access-control vocabulary on deploy, straight from your release pipeline:
var result = await _client.ApplyProvisioningAsync(new ApplyProvisioningRequest
{
AudienceId = audienceId,
SourceVersion = "1.4.0",
Actions = [new() { Key = "read", Name = "Read", Description = "Read access" }],
Resources = [new() { Key = "advisor", Name = "Advisor", Description = "A warehouse advisor" }],
Permissions =
[
new()
{
Key = "read-advisor",
Name = "Read Advisor",
Description = "Read an advisor",
ActionKey = "read",
ResourceKey = "advisor"
}
]
});
Provisioning is additive and idempotent: entries are created or updated by key, never deleted, and the contracts cannot represent role membership, user assignment, or policy activation. GetProvisioningStateAsync returns the last applied version plus anything awaiting human review (orphans, drifts), DismissProvisioningOrphanAsync clears a reviewed orphan flag, and GetPermissionByKeyAsync answers design-time "does this key exist / is it granted" checks without exposing member identities.
What's New in v2.24.0
Confidential client allowed purposes:
SetConfidentialClientAllowedPurposesAsync sets the purposes a confidential client may declare when requesting a token, and GetConfidentialClientAsync now returns ConfidentialClientDto.AllowedPurposes.
What's New in v2.23.1
Fixed GetConfidentialClientAsync deserialization:
GetConfidentialClientAsync previously threw a JsonException because the client ConfidentialClientDto required a CreatedAt field the Portal API never returns. The DTO now matches the server response, so the call deserializes successfully.
What's New in v2.23.0
Create a confidential client with a token endpoint authentication method:
CreateConfidentialClientRequest now exposes an optional TokenEndpointAuthenticationMethod. Provision a secretless (private_key_jwt) client in a single create call instead of create-then-update:
var createResult = await _client.CreateConfidentialClientAsync(new CreateConfidentialClientRequest
{
Name = "Agentlink",
Description = "Machine-to-machine client",
RequireMtls = false,
TokenEndpointAuthenticationMethod = TokenEndpointAuthenticationMethod.PrivateKeyJwt
});
Omitting the field preserves the previous default (ClientSecretBasic).
What's New in v2.22.0
New Features - API Resource Listing:
2 new methods for listing API resources:
| Category | Methods |
|---|---|
| API resource listing | GetApiResourcesAsync (full list, no pagination), GetApiResourcesPagedAsync (paginated) |
Example - List API resources with pagination:
var paged = await _client.GetApiResourcesPagedAsync(new GetApiResourcesPagedRequest
{
SearchText = "billing",
PageNumber = 1,
PageSize = 25
});
if (!paged.IsError)
{
foreach (var apiResource in paged.Value.ApiResources)
Console.WriteLine($"{apiResource.Name} ({apiResource.Identifier})");
}
// Or fetch every matching resource at once:
var all = await _client.GetApiResourcesAsync(new GetApiResourcesRequest { Status = ApiResourceStatus.Active });
What's New in v2.21.0
New Features - API Resources & Access Control:
25 new methods for managing API resources, resource-scoped grants, and access-control introspection:
| Category | Methods |
|---|---|
| API resource lifecycle | CreateApiResourceAsync, GetApiResourceAsync, UpdateApiResourceAsync, DeleteApiResourceAsync, ActivateApiResourceAsync, DeactivateApiResourceAsync, ValidateApiResourceIdentifierAsync |
| Confidential-client assignments | AddApiResourceConfidentialClientAsync, RemoveApiResourceConfidentialClientAsync, AddApiResourceConfidentialClientRoleAsync, RemoveApiResourceConfidentialClientRoleAsync, AddApiResourceConfidentialClientPermissionAsync, RemoveApiResourceConfidentialClientPermissionAsync, GetApiResourceConfidentialClientsAsync |
| User assignments | AddApiResourceUserAsync, RemoveApiResourceUserAsync, AddApiResourceUserRoleAsync, RemoveApiResourceUserRoleAsync, AddApiResourceUserPermissionAsync, RemoveApiResourceUserPermissionAsync, GetApiResourceUsersAsync, GetApiResourceUserAsync |
| Catalog & introspection | GetRolesAsync, GetPermissionsAsync (optional AudienceId scoping), GetEffectivePermissionsAsync |
Example - Create an API resource and grant a confidential client a role:
// Create the API resource
var createResult = await _client.CreateApiResourceAsync(new CreateApiResourceRequest
{
Name = "Orders API",
Description = "Order management service",
Identifier = "https://orders.example.com"
});
var apiResourceId = createResult.Value.ApiResourceId;
// Allow a confidential client to access it
var assignment = await _client.AddApiResourceConfidentialClientAsync(new AddApiResourceConfidentialClientRequest
{
ApiResourceId = apiResourceId,
ConfidentialClientId = confidentialClientId
});
// Grant the client a role at this resource
await _client.AddApiResourceConfidentialClientRoleAsync(new AddApiResourceConfidentialClientRoleRequest
{
ApiResourceId = apiResourceId,
ApiResourceConfidentialClientId = assignment.Value.ApiResourceConfidentialClientId,
RoleId = roleId
});
Example - List a resource's assignable roles and read effective permissions:
// Roles assignable for this API resource (audience-scoped catalog)
var roles = await _client.GetRolesAsync(new GetRolesRequest
{
AudienceId = audienceId,
PageNumber = 1,
PageSize = 50
});
// The authenticated principal's effective permissions, including the requested audiences
var effective = await _client.GetEffectivePermissionsAsync(new GetEffectivePermissionsRequest
{
AudienceIds = [audienceId]
});
// Global permissions have a null AudienceId; per-audience permissions carry the scoping audience
var globalPermissions = effective.Value.Permissions.Where(p => p.AudienceId is null);
See CHANGELOG.md for full version history.
What's New in v2.20.0
New Features - Secretless Confidential Client Authentication:
11 new methods for provisioning private_key_jwt and mutual TLS (mTLS) authentication:
| Category | Methods |
|---|---|
Public keys (private_key_jwt) |
AddConfidentialClientPublicKeyAsync, GetClientPublicKeysAsync, RevokeConfidentialClientPublicKeyAsync, RemoveConfidentialClientPublicKeyAsync |
| Certificates (mTLS) | AddConfidentialClientCertificateAsync, GetClientCertificateAsync, GetClientCertificatesAsync, ActivateConfidentialClientCertificateAsync, DeactivateConfidentialClientCertificateAsync, RemoveConfidentialClientCertificateAsync |
| mTLS requirement | SetConfidentialClientMtlsRequirementAsync |
Example - Register a public key for private_key_jwt:
var keyResult = await _client.AddConfidentialClientPublicKeyAsync(new AddConfidentialClientPublicKeyRequest
{
ConfidentialClientId = confidentialClientId,
KeyType = "RSA",
Use = "sig",
Algorithm = "RS256",
KeyId = "key-2026-01",
N = modulusBase64Url,
E = "AQAB",
NotBefore = DateTime.UtcNow,
NotAfter = DateTime.UtcNow.AddYears(1)
});
var clientPublicKeyId = keyResult.Value.ClientPublicKeyId;
Example - Register a certificate and require mTLS:
await _client.AddConfidentialClientCertificateAsync(new AddConfidentialClientCertificateRequest
{
ConfidentialClientId = confidentialClientId,
Thumbprint = certificateThumbprint,
Subject = "CN=my-service",
NotBefore = DateTime.UtcNow,
NotAfter = DateTime.UtcNow.AddYears(1)
});
await _client.SetConfidentialClientMtlsRequirementAsync(new SetConfidentialClientMtlsRequirementRequest
{
ConfidentialClientId = confidentialClientId,
RequireMtls = true
});
See CHANGELOG.md for full version history.
What's New in v2.19.0
New Features - Confidential Client Management:
9 new methods for managing OAuth2 confidential clients:
| Category | Methods |
|---|---|
| CRUD | CreateConfidentialClientAsync, GetConfidentialClientAsync, GetConfidentialClientsAsync, UpdateConfidentialClientAsync, DeleteConfidentialClientAsync |
| Lifecycle | ActivateConfidentialClientAsync, DeactivateConfidentialClientAsync |
| Secrets | AddConfidentialClientSecretAsync, RemoveConfidentialClientSecretAsync |
Example - Create a confidential client with a secret:
// Create a confidential client
var createResult = await _client.CreateConfidentialClientAsync(new CreateConfidentialClientRequest
{
Name = "Agent Service Client",
Description = "OAuth2 client for agent authentication",
RequireMtls = false
});
// Add a client secret
var secretResult = await _client.AddConfidentialClientSecretAsync(new AddConfidentialClientSecretRequest
{
ConfidentialClientId = createResult.Value.ConfidentialClientId,
NotBefore = DateTime.UtcNow,
NotAfter = DateTime.UtcNow.AddYears(1)
});
// The secret value is only returned once
var clientSecret = secretResult.Value.ClientSecret;
New Features - Agent Improvements:
| Method | Description |
|---|---|
AgentExistsAsync |
Lightweight existence check without fetching the full agent |
GetAgentsAsync |
Non-paged list of all agents matching filters |
GetAgentsPagedAsync |
Paged list with pagination metadata (renamed from GetAgentsAsync) |
Example - Manage User Custom Data:
// Add custom data
await _client.AddUserCustomDataAsync(new AddUserCustomDataRequest
{
UserId = userId,
Key = "department",
Value = "Engineering"
});
// Remove custom data
await _client.RemoveUserCustomDataAsync(new RemoveUserCustomDataRequest
{
UserId = userId,
Key = "department"
});
See CHANGELOG.md for full version history.
Usage
Setup
builder.Services.AddPortalHttpClient(options =>
{
options.BaseUrl = "https://ui.portal.authlink.co.za";
options.AccessToken = "your-access-token";
});
Basic Usage
public class MyService
{
private readonly IPortalClient _client;
public MyService(IPortalClient client)
{
_client = client;
}
public async Task GetUsersAsync()
{
var result = await _client.GetUsersAsync(new GetUsersRequest
{
PageNumber = 1,
PageSize = 10
});
if (result.IsError)
{
var error = result.FirstError;
Console.WriteLine($"Error: {error.Code} - {error.Description}");
return;
}
var response = result.Value;
Console.WriteLine($"Found {response.TotalCount} users");
}
}
Pattern Matching
var result = await _client.GetUserByIdAsync(new GetUserByIdRequest { UserId = userId });
return result.Match(
user => Ok(user),
errors => errors[0].Type switch
{
ErrorType.NotFound => NotFound(),
ErrorType.Unauthorized => Unauthorized(),
ErrorType.Forbidden => Forbid(),
_ => Problem(errors[0].Description)
}
);
Error Types
| Error Code | Error Type | HTTP Status | Description |
|---|---|---|---|
Portal.ValidationFailed |
Validation | 400 | Request validation failed |
Portal.Unauthorized |
Unauthorized | 401 | Authentication required |
Portal.Forbidden |
Forbidden | 403 | Insufficient permissions |
Portal.NotFound |
NotFound | 404 | Resource not found |
Portal.Conflict |
Conflict | 409 | Resource conflict |
Portal.Timeout |
Failure | 408 | Request timed out |
Portal.NetworkError |
Failure | - | Network/connection error |
Portal.HttpRequestFailed |
Failure | other | Any other non-success status |
Error responses from the Portal API are RFC 7807 ProblemDetails: the title becomes
the error Description, detail (when present) is exposed as ProblemDetail
metadata, and the raw body remains available as ResponseBody metadata.
Authenticate your automation client
The recommended way to authenticate scripted or pipeline consumers is the built-in
client-credentials provider: configure ClientCredentials and the SDK acquires a portal token
from the Identity token endpoint, caches it until expiry (minus a configurable ExpirySkew),
refreshes it thread-safely, and retries a request once with a fresh token if the portal answers 401.
Failures surface as the typed Portal.TokenAcquisitionFailed error, never an opaque 401.
builder.Services.AddPortalHttpClient(options =>
{
options.BaseUrl = "https://ui.portal.authlink.co.za";
options.ClientCredentials = new ClientCredentialsOptions
{
// The Identity server's OAuth token endpoint.
TokenEndpoint = "https://identity.authlink.co.za/api/connect/token",
ClientId = configuration["Authlink:Portal:ClientId"]!,
ClientSecret = configuration["Authlink:Portal:ClientSecret"]!,
// Optional: the audience the Portal API validates. This is the `Audience` value
// configured on the Portal host — ask your Authlink operator if unsure.
Audience = "https://portal.authlink.co.za",
// Optional: scopes to request, sent space-delimited.
Scopes = ["portal"]
};
});
One-time bootstrap
The automation client itself is provisioned once, by hand:
- In the portal UI, create a confidential client for your automation (Clients → Confidential Clients → Create). Note the generated
ClientIdand add a secret. - Grant the client the admin roles/permissions the automation needs (e.g.
user-adminfor user management,api-resource-adminfor resource provisioning). Least privilege applies — grant only the surfaces your scripts call. - Store the
ClientId/ClientSecretin your secret store and configure them as above.
From then on, every other entity (users, public clients, API resources, permissions, roles, policies) can be onboarded through IPortalClient with zero manual token plumbing.
Other Authentication Options
Static Token
builder.Services.AddPortalHttpClient(options =>
{
options.BaseUrl = "https://ui.portal.authlink.co.za";
options.AccessToken = configuration["Authlink:Portal:AccessToken"];
});
Custom Token Provider
A custom provider registered before AddPortalHttpClient always takes precedence, including over
ClientCredentials:
builder.Services.AddScoped<IAccessTokenProvider, MyTokenProvider>();
builder.Services.AddPortalHttpClient(options =>
{
options.BaseUrl = "https://ui.portal.authlink.co.za";
});
Runtime Token Updates
if (_tokenProvider is MutableAccessTokenProvider mutableProvider)
{
mutableProvider.SetAccessToken(newToken);
}
Testing
The package includes comprehensive integration tests. See Integration Tests Documentation.
Documentation
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- Authlink.Portal.Client.Core (>= 3.0.1)
- ErrorOr (>= 2.0.1)
- Microsoft.Extensions.DependencyInjection (>= 10.0.11)
- Microsoft.Extensions.Http (>= 10.0.11)
- Microsoft.Extensions.Options (>= 10.0.11)
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 |
|---|---|---|
| 3.3.0 | 343 | 11/17/2026 |
| 3.0.1 | 1,536 | 10/6/2026 |
| 3.0.0 | 116 | 10/6/2026 |
| 2.34.0 | 220 | 9/21/2026 |
| 2.33.0 | 117 | 9/21/2026 |
| 2.32.1 | 109 | 10/2/2026 |
| 2.32.0 | 934 | 9/16/2026 |
| 2.31.0 | 113 | 9/16/2026 |
| 2.30.0 | 304 | 9/14/2026 |
| 2.29.2 | 777 | 9/7/2026 |
| 2.29.1 | 134 | 9/7/2026 |
| 2.29.0 | 347 | 8/31/2026 |
| 2.28.0 | 130 | 8/31/2026 |
| 2.27.0 | 182 | 8/21/2026 |
| 2.26.1 | 323 | 8/14/2026 |
| 2.26.0 | 134 | 8/11/2026 |
| 2.25.2 | 146 | 7/22/2026 |
| 2.25.1 | 137 | 7/17/2026 |
| 2.25.0 | 124 | 7/15/2026 |
| 2.24.0 | 144 | 7/14/2026 |