HelseID.Library.ClientCredentials
1.1.3
Prefix Reserved
dotnet add package HelseID.Library.ClientCredentials --version 1.1.3
NuGet\Install-Package HelseID.Library.ClientCredentials -Version 1.1.3
<PackageReference Include="HelseID.Library.ClientCredentials" Version="1.1.3" />
<PackageVersion Include="HelseID.Library.ClientCredentials" Version="1.1.3" />
<PackageReference Include="HelseID.Library.ClientCredentials" />
paket add HelseID.Library.ClientCredentials --version 1.1.3
#r "nuget: HelseID.Library.ClientCredentials, 1.1.3"
#:package HelseID.Library.ClientCredentials@1.1.3
#addin nuget:?package=HelseID.Library.ClientCredentials&version=1.1.3
#tool nuget:?package=HelseID.Library.ClientCredentials&version=1.1.3
HelseId.Library
The easiest way to integrate with HelseID! This library conforms to the requirements from the HelseID security profile for the client credentials grant (also known as machine-to-machine).
To get started with HelseID
See the docs on https://selvbetjening.nhn.no/docs
How to use the library:
You start by installing the NuGet package HelseID.Library.ClientCredentials.
The simplest setting is where the configuration is hard-coded:
// This comes from the .NET Generic Host (https://learn.microsoft.com/en-us/dotnet/core/extensions/generic-host?tabs=appbuilder)
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
var helseIdConfiguration = new HelseIdConfiguration
{
ClientId = "7e3816ca-7d11-41cd-be55-fb9e8954e058",
Scope = "nhn:hgd-persontjenesten-api/restricted-access nhn:selvbetjening/client",
IssuerUri = "https://helseid-sts.test.nhn.no",
};
builder.Services
.AddHelseIdClientCredentials(helseIdConfiguration)
.AddJwkForClientAuthentication(YOUR_PRIVATE_KEY_HERE);
var host = builder.Build();
host.Run();
// The service is now configured
Later on you will need to use an instance of the IHelseIdClientCredentialsFlow to retrieve an Access token response:
// This is constructed by the service locator
IHelseIdClientCredentialsFlow helseIdClientCredentialsFlow;
...
var tokenResponse = await helseIdClientCredentialsFlow.GetTokenResponseAsync();
// If the token response is successful, you will get an AccessTokenResponse object:
if (tokenResponse.IsSuccessful(out var accessTokenResponse))
{
...
}
else
{
// If the token response failed, you can inspect the error response from the TokenErrorResponse object:
var errorResponse = tokenResponse.AsError();
Console.WriteLine(errorResponse.Error + " " + errorResponse.ErrorDescription);
...
}
If you have a multi-tenant client, you will probably need to setup organization numbers; see the document Performing token requests for this scenario.
To retrieve a DPoP Proof you can use the IDPoPProofCreatorForApiRequests:
...
// This is constructed by the service locator
IDPoPProofCreatorForApiRequests dPoPProofCreator;
var url = "URL TO THE HTTP ENDPOINT";
var dPoPProof = await dPoPProofCreator.CreateDPoPProofForApiRequest(HttpMethod.Get, url, accessTokenResponse);
...
Finally, to make a request to an API you can do the following: using our SetDPoPTokenAndProof extension method to set both Access Token and DPoP proof on the HTTP request:
...
var apiRequest = new HttpRequestMessage(HttpMethod.Get, url);
apiRequest.SetDPoPTokenAndProof(accessTokenResponse, dPoPProof);
var response = await httpClient.SendAsync(apiRequest);
...
Read more here:
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. 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 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
- HelseID.Library (>= 1.1.3)
-
net8.0
- HelseID.Library (>= 1.1.3)
-
net9.0
- HelseID.Library (>= 1.1.3)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on HelseID.Library.ClientCredentials:
| Package | Downloads |
|---|---|
|
Helsenorge.Registries
Helsenorge messaging registry support |
|
|
HelseID.Library.Mocks
Mock implementations of relevant classes from HelseId.Library |
|
|
HelseID.Library.SelfService
This package implements library communication with the HelseID SelfService API |
|
|
Helsedir.Fkr.Shared.Client
Contains client for the Felles Kontaktregister (FKR). |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.3 | 4,239 | 3/17/2026 |
| 1.1.2 | 1,829 | 1/22/2026 |
| 1.1.1 | 1,457 | 1/14/2026 |
| 1.1.0 | 275 | 1/8/2026 |
| 1.0.0 | 1,179 | 11/12/2025 |
| 0.9.4 | 887 | 11/5/2025 |
| 0.9.3 | 304 | 11/3/2025 |
| 0.9.2 | 215 | 10/31/2025 |
| 0.9.1 | 324 | 10/27/2025 |
| 0.9.0 | 241 | 10/22/2025 |
| 0.1.14 | 890 | 10/8/2025 |
| 0.1.13 | 481 | 10/2/2025 |
| 0.1.12 | 215 | 9/26/2025 |
| 0.1.11 | 272 | 8/26/2025 |