Currently the DotNet Core Nuget package only supports a 64 bit Windows environment. We are working towards cross platform compatibility targetted at the first half of 2020.
The full itsme® DotNet Core code sample snippet can be found here.
Install the itsme® NuGet package to your project to get started.
$ dotnet add <myproject> itsme
Import the itsme® project into your code.
using Itsme;
Initialize the itsme® client with your configuration. Replace the relevant parts with your data:
my_private_jwks.json
with your actual key file contentmy_client_id
with the client ID received by itsme®ItsmeSettings.Production
by the environment you want to usevar jwks = File.ReadAllText("jwks_private.json");
var settings = new ItsmeSettings();
settings.ClientId = "my_client_id";
settings.PrivateJwkSet = jwks;
settings.Environment = Itsme.Environment.production;
var itsmeClient = new Client(settings);
Create a URI that starts the user identification by providing the needed configuration.
scopes
you want to usemy_service_code
with the service received by itsme® for the relevant serviceRequestUri
in case your want to use onevar urlConfig = new UrlConfiguration();
urlConfig.Scopes = new List<Itsme.Scope>(){
Itsme.Scope.profile,
Itsme.Scope.email,
Itsme.Scope.address,
Itsme.Scope.phone
};
urlConfig.ServiceCode = "MY_SERVICE_CODE";
urlConfig.RedirectUri = "https://example.com/production/redirect";
var url = itsmeClient.GetAuthenticationURL(urlConfig);
In case you need additional data from the user or want to use a different service requiring the use of a request_uri
, you can create the signed and encrypted JWT using the built-in CreateRequestURIPayload
function.
var requestSettings = new Itsme.RequestUriConfiguration();
requestSettings.ServiceCode = "MY_SERVICE_CODE";
requestSettings.Scopes = new List<Itsme.Scope>(){
Itsme.Scope.profile,
Itsme.Scope.email,
Itsme.Scope.address,
Itsme.Scope.phone
};
requestSettings.RedirectUri = "https://example.com/production/redirect";
requestSettings.AcrValue = Itsme.AcrValue.ACRAdvanced;
requestSettings.Nonce = "a_valid_nonce";
requestSettings.State = "a_valid_state";
var data = itsmeClient.CreateRequestURIPayload(requestSettings);
The possible ACRValue
values are:
ACRBasic
- Allow fingerprint authenticationACRAdvanced
- Force PIN entryThe Share data service differs itself from the Login service in that you must at least specify one Claim in the request_uri
object.
requestSettings.Claims = new List<Itsme.Claim>(){
Itsme.Claim.ClaimEid,
Itsme.Claim.ClaimCityOfBirth
};
The following Claims are available:
ClaimEid
- Request the user’s E-ID dataClaimCityOfBirth
- Request the user’s city of birthClaimNationality
- Request the user’s nationalityClaimDevice
- Request the user’s device informationClaimPhoto
- Request the user’s profile pictureIf the user is successfully authenticated and authorises access to the data requested, itsme® will return a code to your server component. This is achieved by returning an Authentication Response, which is a HTTP 302 redirect request to the redirect URI specified previously.
When using the Confirm service you have the option to use two templates, free text and advanced payment.
Free text allows you to add a guiding text containing more stylized content to offer information to the user in the itsme® app. The following charcters are supported:
<i>
for italic text<b>
for bold text<u>
for underlined text</br>
for line breaksrequestSettings.FreeTextTemplate = new Itsme.FreeTextTemplate();
requestSettings.FreeTextTemplate.Text = "This is <b>me</b> in bold.</br>This is <i>me</i> in italic.</br>This is <u>me</u> in underline.";
Advanced payment is used when you want to add contextual information regarding a payment transfer. The itsme® app will render it a layout highlighting this information to the user.
requestSettings.AdvancedPaymentTemplate = new Itsme.AdvancedPaymentTemplate();
requestSettings.AdvancedPaymentTemplate.Amount = "20";
requestSettings.AdvancedPaymentTemplate.Currency = "EUR";
requestSettings.AdvancedPaymentTemplate.IBAN = "BE68539007547034";
Once your server component has received a code, it can exchange it for an user’s unique identifier and his attributes.
var data = new Itsme.RedirectData();
data.Code = authorization_code;
data.RedirectUri = "https://example.com/production/redirect";
var user = itsmeClient.GetUserDetails(data);
Make sure to only use the sub
identifier to link or reference an itsme® user from your data as all other parameters can be subject to change.