Authlink.Portal.Client.Http
2.16.0
See the version list below for details.
dotnet add package Authlink.Portal.Client.Http --version 2.16.0
NuGet\Install-Package Authlink.Portal.Client.Http -Version 2.16.0
<PackageReference Include="Authlink.Portal.Client.Http" Version="2.16.0" />
<PackageVersion Include="Authlink.Portal.Client.Http" Version="2.16.0" />
<PackageReference Include="Authlink.Portal.Client.Http" />
paket add Authlink.Portal.Client.Http --version 2.16.0
#r "nuget: Authlink.Portal.Client.Http, 2.16.0"
#:package Authlink.Portal.Client.Http@2.16.0
#addin nuget:?package=Authlink.Portal.Client.Http&version=2.16.0
#tool nuget:?package=Authlink.Portal.Client.Http&version=2.16.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.14.0
New Features - User Roles, Permissions, Attributes, Custom Data, and Policies:
19 new methods for managing user relationships:
| Category | Methods |
|---|---|
| Roles | GetUserRolesAsync, GetUserRoleAsync, AddUserRoleAsync, RemoveUserRoleAsync |
| Permissions | GetUserPermissionsAsync, GetUserPermissionAsync, AddUserPermissionAsync, RemoveUserPermissionAsync |
| Attributes | GetUserAttributesAsync, GetUserAttributeAsync, AddUserAttributeAsync, UpdateUserAttributeAsync, RemoveUserAttributeAsync |
| Custom Data | AddUserCustomDataAsync, RemoveUserCustomDataAsync |
| Policies | GetUserPoliciesAsync, GetUserPolicyAsync, AddUserPolicyAsync, RemoveUserPolicyAsync |
Example - Manage User Roles:
// Add a role to a user
var addResult = await _client.AddUserRoleAsync(new AddUserRoleRequest
{
UserId = userId,
RoleId = roleId
});
// List user roles with pagination
var rolesResult = await _client.GetUserRolesAsync(new GetUserRolesRequest
{
UserId = userId,
PageNumber = 1,
PageSize = 10
});
// Remove a role from a user
var removeResult = await _client.RemoveUserRoleAsync(new RemoveUserRoleRequest
{
UserId = userId,
UserRoleId = userRoleId
});
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.16.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 | 56 | 6/10/2026 |
| 2.17.0 | 123 | 5/19/2026 |
| 2.16.0 | 113 | 4/28/2026 |
| 2.15.0 | 102 | 4/24/2026 |
| 2.14.0 | 109 | 4/16/2026 |
| 2.13.0 | 110 | 3/26/2026 |
| 2.12.1 | 113 | 3/13/2026 |
| 2.12.0 | 118 | 3/12/2026 |
| 2.11.0 | 111 | 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 |