Authlink.Portal.Client.Http
2.19.0
dotnet add package Authlink.Portal.Client.Http --version 2.19.0
NuGet\Install-Package Authlink.Portal.Client.Http -Version 2.19.0
<PackageReference Include="Authlink.Portal.Client.Http" Version="2.19.0" />
<PackageVersion Include="Authlink.Portal.Client.Http" Version="2.19.0" />
<PackageReference Include="Authlink.Portal.Client.Http" />
paket add Authlink.Portal.Client.Http --version 2.19.0
#r "nuget: Authlink.Portal.Client.Http, 2.19.0"
#:package Authlink.Portal.Client.Http@2.19.0
#addin nuget:?package=Authlink.Portal.Client.Http&version=2.19.0
#tool nuget:?package=Authlink.Portal.Client.Http&version=2.19.0
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.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 | 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 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. |
-
net9.0
- Authlink.Portal.Client.Core (>= 2.19.0)
- ErrorOr (>= 2.0.1)
- Microsoft.Extensions.DependencyInjection (>= 9.0.9)
- Microsoft.Extensions.Http (>= 9.0.9)
- Microsoft.Extensions.Options (>= 9.0.9)
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 |
|---|---|---|
| 2.19.0 | 0 | 6/10/2026 |
| 2.17.0 | 121 | 5/19/2026 |
| 2.16.0 | 113 | 4/28/2026 |
| 2.15.0 | 101 | 4/24/2026 |
| 2.14.0 | 108 | 4/16/2026 |
| 2.13.0 | 109 | 3/26/2026 |
| 2.12.1 | 112 | 3/13/2026 |
| 2.12.0 | 117 | 3/12/2026 |
| 2.11.0 | 110 | 3/11/2026 |
| 2.10.0 | 108 | 3/6/2026 |
| 2.9.0 | 109 | 2/18/2026 |
| 2.8.0 | 112 | 2/18/2026 |
| 2.7.0 | 128 | 1/30/2026 |
| 2.6.0 | 113 | 1/29/2026 |
| 2.5.0 | 121 | 1/29/2026 |
| 2.4.0 | 114 | 1/28/2026 |
| 2.3.0 | 126 | 1/7/2026 |
| 2.2.4 | 112 | 1/7/2026 |
| 2.2.3 | 119 | 1/7/2026 |
| 2.2.2 | 314 | 11/12/2025 |