Energinet.DataHub.MarketParticipant.Authorizations.Client
1.0.517
Prefix Reserved
dotnet add package Energinet.DataHub.MarketParticipant.Authorizations.Client --version 1.0.517
NuGet\Install-Package Energinet.DataHub.MarketParticipant.Authorizations.Client -Version 1.0.517
<PackageReference Include="Energinet.DataHub.MarketParticipant.Authorizations.Client" Version="1.0.517" />
<PackageVersion Include="Energinet.DataHub.MarketParticipant.Authorizations.Client" Version="1.0.517" />
<PackageReference Include="Energinet.DataHub.MarketParticipant.Authorizations.Client" />
paket add Energinet.DataHub.MarketParticipant.Authorizations.Client --version 1.0.517
#r "nuget: Energinet.DataHub.MarketParticipant.Authorizations.Client, 1.0.517"
#:package Energinet.DataHub.MarketParticipant.Authorizations.Client@1.0.517
#addin nuget:?package=Energinet.DataHub.MarketParticipant.Authorizations.Client&version=1.0.517
#tool nuget:?package=Energinet.DataHub.MarketParticipant.Authorizations.Client&version=1.0.517
Authorizations Client
.NET client package for the Authorizations API (v1).
Installation
dotnet add package Energinet.DataHub.MarketParticipant.Authorizations.Client
Registration
Register the client in your dependency injection container using one of the two available overloads.
Using the ambient IConfiguration (recommended)
Reads options from the IConfiguration already registered in the DI container:
services.AddAuthorizationClient();
Using an explicit IConfiguration instance
Useful when you want to pass a specific configuration object:
services.AddAuthorizationClient(configuration);
Both overloads register AuthorizationsClient as a typed HttpClient and validate the options at startup.
Configuration
Options are bound from the AuthorizationClient section of your configuration (e.g. appsettings.json):
{
"AuthorizationClient": {
"BaseUrl": "https://authorizations.example.com"
}
}
Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
BaseUrl |
Uri |
Yes | — | Absolute base URL of the Authorizations API. Must be an absolute URI. |
HTTP timeout behavior is configured through the AuthorizationsHttpClientResilience section.
Resilience options
The client uses AddStandardResilienceHandler() and binds HttpStandardResilienceOptions from the AuthorizationsHttpClientResilience section.
The effective resilience settings are built by merging:
- Internal defaults from the client package.
- Values from your
AuthorizationsHttpClientResilienceconfiguration section.
This means you can provide only the values you want to override.
Default resilience values
| Path | Default |
|---|---|
AuthorizationsHttpClientResilience:Retry:Delay |
00:00:02 |
AuthorizationsHttpClientResilience:Retry:BackoffType |
Exponential |
AuthorizationsHttpClientResilience:Retry:MaxRetryAttempts |
4 |
AuthorizationsHttpClientResilience:Retry:UseJitter |
true |
Example override
{
"AuthorizationsHttpClientResilience": {
"Retry": {
"MaxRetryAttempts": 7,
"Delay": "00:00:05"
}
}
}
In this example, BackoffType and UseJitter still come from the defaults.
Usage
This client supports two primary usage patterns:
1. Getting Authorization Tokens (Origin System)
Retrieve an AuthorizationContext that can be passed to downstream systems:
public class AuthorizationTokenService(AuthorizationsClient client)
{
public async Task<AuthorizationContext> GetTokenForSubjectAsync(Guid subjectId, CancellationToken ct = default)
{
return await client.AuthorizationContextForSubjectAsync(subjectId, ct);
}
public async Task<AuthorizationContext> GetTokenForActorAsync(string gln, MarketRoles role, CancellationToken ct = default)
{
return await client.AuthorizationContextForActorAsync(gln, role, ct);
}
}
The returned AuthorizationContext contains the token (signature) and claims, which should be transmitted to downstream systems.
2. Validating Tokens & Extracting Policies (Downstream System)
Use PolicyFactory to validate an incoming AuthorizationContext and resolve policies:
public class AuthorizationService(PolicyFactory policyFactory)
{
public async Task<MeteringPointAccessPolicy> ValidateAndGetPolicyAsync(
AuthorizationContext context,
CancellationToken ct = default)
{
return await policyFactory.GetPolicy<MeteringPointAccessPolicy>(context, ct);
}
}
The PolicyFactory will:
- Retrieve the public key from the provider
- Validate the authorization context signature
- Extract and return the strongly-typed policy
If validation fails, an InvalidOperationException is thrown.
Testing Environment
For testing scenarios where signature verification should be bypassed, register the test double after the main client registration:
public void ConfigureServices(IServiceCollection services)
{
services
.AddAuthorizationClient(configuration)
.AddBypassSignatureVerificationForTesting();
}
This substitutes the standard key provider with one that accepts all signatures, allowing you to focus on business logic validation without dealing with cryptographic concerns.
⚠️ Never use in production — this is test-only functionality.
A context can be created with AuthorizationContextBuilder for testing purposes:
var context = var policy = AuthorizationContextBuilder.Create()
.WithMeteringPointAccess("mp-1", MeteringPointSubjectRelation.Occupancy, TestTime.AddDays(-1), TestTime.AddDays(1))
.WithMeteringPointAccess("mp-2", MeteringPointSubjectRelation.Occupancy, TestTime.AddDays(-1), TestTime.AddDays(1))
.BuildContext();
If needed, you can then pass this context to the PolicyFactory to get a policy instance for testing:
var policy = await BypassSignaturePolicyFactory.Instance
.GetPolicy<MeteringPointAccessPolicy>(context, CancellationToken.None);
For maintainers
How this package is published
The client code in this project is automatically generated from the file-based OpenAPI contract at ../Energinet.DataHub.MarketParticipant.Authorizations.Api/OpenApi/Energinet.DataHub.MarketParticipant.Authorizations.Api.json (via NSwag). You never edit AuthorizationsClient.g.cs by hand.
The contract file is produced by building Energinet.DataHub.MarketParticipant.Authorizations.Api (code-first controllers + OpenAPI generation).
When you build the client and the contract file is missing, an MSBuild bootstrap target in the client automatically builds the API first to generate the contract file.
Typical local flow:
- Build the API project to refresh the OpenAPI contract file.
- Build the client project to regenerate
AuthorizationsClient.g.csfrom that contract.
Publishing is handled by the CI workflow .github/workflows/publish-authorizations-client-bundle.yml. It triggers automatically when any file under Authorizations.Api/ or Authorizations.Client/ is merged to main, and:
- Builds the full Authorizations solution (which regenerates the OpenAPI contract and then regenerates the client from that file contract).
- Runs unit tests.
- Packs and pushes the NuGet package.
You do not need to do anything manually to publish a new version.
Versioning
Versioning is handled automatically by Nerdbank.GitVersioning. The published version is derived from the base version in version.json combined with the git commit height (number of commits on main since the repo root):
| Branch | Example version | Published to NuGet? |
|---|---|---|
main |
1.0.42 |
Yes |
| feature branch | 1.0.42-gabcdef1 |
No (pre-release) |
When to edit version.json
version.json only needs to be edited for intentional breaking or significant changes that warrant a major or minor version bump. The patch number is always automatic.
| Scenario | Action |
|---|---|
| Add/change/remove an API endpoint — backwards compatible | Do nothing. Patch auto-increments on merge. |
| Add/change/remove an API endpoint — breaking change | Bump minor (e.g. 1.0 → 1.1) or major (e.g. 1.0 → 2.0) in version.json. |
Accidental version conflict (e.g. rolling back version.json) |
The pre-merge version guard workflow will catch this and fail the PR. |
To bump, open version.json and change the version field:
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "2.0",
"publicReleaseRefSpec": [
"^refs/heads/main$"
]
}
Note: A PR that changes
version.jsonwill automatically trigger the version guard workflow (.github/workflows/ci-authorizations-client-version-guard.yml), which queries NuGet.org and fails the PR if themajor.minorcombination is already in use.
| 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
- Microsoft.Extensions.Configuration.Binder (>= 10.0.9)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Http (>= 10.0.9)
- Microsoft.Extensions.Http.Resilience (>= 10.7.0)
- Microsoft.Extensions.Options (>= 10.0.9)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Energinet.DataHub.MarketParticipant.Authorizations.Client:
| Package | Downloads |
|---|---|
|
Energinet.DataHub.Measurements.Client
[Release Notes](https://github.com/Energinet-DataHub/opengeh-measurements/blob/main/docs/Measurements.Client/ReleaseNotes/ReleaseNotes.md) [Documentation](https://github.com/Energinet-DataHub/opengeh-measurements/blob/main/docs/Measurements.Client/Documentation.md) |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.517 | 36 | 6/18/2026 |
| 1.0.511 | 46 | 6/18/2026 |
| 1.0.510 | 44 | 6/18/2026 |
| 1.0.506 | 47 | 6/18/2026 |
| 1.0.504 | 42 | 6/18/2026 |
| 1.0.502 | 55 | 6/18/2026 |
| 1.0.495 | 48 | 6/17/2026 |
| 1.0.493 | 48 | 6/17/2026 |
| 1.0.492 | 40 | 6/17/2026 |
| 1.0.488 | 48 | 6/17/2026 |
| 1.0.482 | 146 | 6/16/2026 |
| 1.0.480 | 45 | 6/16/2026 |
| 1.0.475 | 255 | 6/15/2026 |
| 1.0.474 | 88 | 6/15/2026 |
| 1.0.472 | 90 | 6/15/2026 |
| 1.0.470 | 92 | 6/15/2026 |
| 1.0.466 | 86 | 6/15/2026 |
| 1.0.464 | 525 | 6/12/2026 |
| 1.0.459 | 95 | 6/11/2026 |
| 1.0.456 | 97 | 6/11/2026 |