Authlink.Portal.Client.Http
2.32.1
See the version list below for details.
dotnet add package Authlink.Portal.Client.Http --version 2.32.1
NuGet\Install-Package Authlink.Portal.Client.Http -Version 2.32.1
<PackageReference Include="Authlink.Portal.Client.Http" Version="2.32.1" />
<PackageVersion Include="Authlink.Portal.Client.Http" Version="2.32.1" />
<PackageReference Include="Authlink.Portal.Client.Http" />
paket add Authlink.Portal.Client.Http --version 2.32.1
#r "nuget: Authlink.Portal.Client.Http, 2.32.1"
#:package Authlink.Portal.Client.Http@2.32.1
#addin nuget:?package=Authlink.Portal.Client.Http&version=2.32.1
#tool nuget:?package=Authlink.Portal.Client.Http&version=2.32.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 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://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 |
Authentication Options
Option 1: Static Token (Recommended)
builder.Services.AddPortalHttpClient(options =>
{
options.BaseUrl = "https://portal.authlink.co.za";
options.AccessToken = configuration["Authlink:Portal:AccessToken"];
});
Option 2: Custom Token Provider
builder.Services.AddScoped<IAccessTokenProvider, MyTokenProvider>();
builder.Services.AddPortalHttpClient(options =>
{
options.BaseUrl = "https://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 (>= 2.32.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 |