KS.Fiks.Maskinporten.Client
1.1.5
See the version list below for details.
dotnet add package KS.Fiks.Maskinporten.Client --version 1.1.5
NuGet\Install-Package KS.Fiks.Maskinporten.Client -Version 1.1.5
<PackageReference Include="KS.Fiks.Maskinporten.Client" Version="1.1.5" />
paket add KS.Fiks.Maskinporten.Client --version 1.1.5
#r "nuget: KS.Fiks.Maskinporten.Client, 1.1.5"
// Install KS.Fiks.Maskinporten.Client as a Cake Addin #addin nuget:?package=KS.Fiks.Maskinporten.Client&version=1.1.5 // Install KS.Fiks.Maskinporten.Client as a Cake Tool #tool nuget:?package=KS.Fiks.Maskinporten.Client&version=1.1.5
fiks-maskinporten-dotnet
.net core library for maskinporten authorization through ID-porten
Installation
Install KS.Fiks.Maskinporten.Client nuget package in your .net project.
Example
Setup configuration
Using factory for VER2 and PROD environments
// For VER2 (test)
var maskinportenConfigVer2 = MaskinportenClientConfigurationFactory.CreateVer2Configuration("ver2_issuer", testCertificate);
// For PROD
var maskinportenConfigProd = MaskinportenClientConfigurationFactory.CreateProdConfiguration("prod_issuer", certificate);
Complete configuration
var maskinportenConfig = new MaskinportenClientConfiguration(
audience: @"https://ver2.maskinporten.no/", // ID-porten audience path
tokenEndpoint: @"https://ver2.maskinporten.no/token", // ID-porten token path
issuer: @"oidc_ks_test", // Issuer name, heter nå Integrasjonens identifikator i selvbetjeningsløsningen til DigDir
numberOfSecondsLeftBeforeExpire: 10, // The token will be refreshed 10 seconds before it expires
certificate: /* virksomhetssertifikat as a X509Certificate2 */,
consumerOrg: /* optional value. Sets header consumer_org */);
DigDir maintains a list of well-know endpoints and configuration for the available environments
Create instance of MaskinportenClient
var maskinportenClient = new MaskinportenClient(maskinportenConfig);
Get access token
var scope = "ks:fiks"; // Scope for access token
var accessToken = await maskinportenClient.GetAccessToken(scope);
Get delegated access token
var scope = "ks:fiks"; // Scope for access token
var consumerOrgNo = ...; // Official 9 digit organization number for an organization that has delegated access to you in ALTINN
var accessToken = await maskinportenClient.GetDelegatedAccessToken(consumerOrgNo, scope);
For more information on this feature, check the delegation documentation at DigDir
Get on behalf of access token
This is a feature with limited usecase
var scope = "ks:fiks"; // Scope for access token
var consumerOrgNo = ...; // Official 9 digit organization number for an organization that has delegated access to you in ALTINN
var accessToken = await maskinportenClient.GetOnBehalfOfAccessToken(consumerOrgNo, scope);
For more information on this feature, check the onbehalfof documentation at DigDir
Please note that as stated in the documentation at DigDir, "Det gir ingen mening å bruke onbehalfof for Maskinporten-integrasjoner", means that for most cases it is not usable and is planned for removal. When it is removed this feature will be removed from this client too.
Send request using access token
var httpClient = new HttpClient();
using (var requestMessage = new HttpRequestMessage(HttpMethod.Post, /* api uri */))
{
// Set authorization header with maskinporten access token
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Token);
/* Set other headers. Integration id and password etc.*/
// Send message
var response = await httpClient.SendAsync(requestMessage);
/* Handle response */
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.1
- JWT (>= 10.0.1)
- Newtonsoft.Json (>= 13.0.2)
-
.NETStandard 2.0
- JWT (>= 10.0.1)
- Newtonsoft.Json (>= 13.0.2)
-
net6.0
- JWT (>= 10.0.1)
- Newtonsoft.Json (>= 13.0.2)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on KS.Fiks.Maskinporten.Client:
Package | Downloads |
---|---|
KS.Fiks.IO.Send.Client
Package Description |
|
KS.Fiks.IO.Client
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.1.10 | 43,053 | 1/15/2024 |
1.1.9 | 11,760 | 11/10/2023 |
1.1.8 | 487 | 11/7/2023 |
1.1.7 | 23,062 | 8/15/2023 |
1.1.6 | 585 | 5/31/2023 |
1.1.5 | 47,564 | 1/23/2023 |
1.1.4 | 543 | 1/23/2023 |
1.1.3 | 3,501 | 11/3/2022 |
1.1.2 | 13,833 | 7/1/2022 |
1.1.1 | 28,229 | 12/21/2021 |
1.1.0 | 306 | 12/21/2021 |
1.0.7 | 29,631 | 5/10/2021 |
1.0.6 | 1,690 | 11/13/2020 |
1.0.5 | 3,316 | 11/9/2020 |
1.0.4 | 461 | 11/9/2020 |
1.0.3 | 637 | 9/30/2020 |
1.0.2 | 575 | 8/20/2020 |
1.0.1 | 563 | 6/29/2020 |
1.0.0 | 7,119 | 5/6/2019 |
0.0.6 | 725 | 5/6/2019 |