Last modified: Jul 10, 2024

Setting up Maskinporten client

Maskinporten client

To use the Altinn API, several scenarios require a Maskinporten client:

  • Calling the Altinn API as an organization
  • Authenticating as an enterprise user
  • Authenticating as a system user

Setting up Maskinporten Integration

Maskinporten clients is managed in Samarbeidsportalen test environment

Maskinporten
Setting up client

Selecting scopes

Depending of usage you would need to select the correct scopes

Maskinporten
Setting up client

ScopeUsageDescription
altinn:instances.readAltinn Apps API read
altinn:instances.writeAltinn Apps API write
altinn:authentication/systemregisterAccess to system registerFor system providers that need to mange systems available in system register
altinn:authorization/authorizeAccess to PDP endpointFor orgs that need to authorize access

For legacy list of scopes see here.

Creating JWK

You need to give your own JWK for the client. One option to create JWK is to use Altinn JWKS tool for this.

Available here

PS C:\keys> altinn-jwks create testklient
Generating key testklient-TEST.2024-07-10
Generating key testklient-PROD.2024-07-10
PS C:\keys> altinn-jwks export maskinporten testklient
[{"alg":"RS256","e":"AQAB","key_ops":[],"kid":"testklient-TEST.2024-07-10","kty":"RSA","n":"va4lqufzxUFe9WkTnmA7EvJ0G6LT1MHpDqSepil_F6JZJ7quG8t65pSMJVu-BDlVNep9KTikmnZLks0ifaI60vsvV0JbvU6DtGNmA8QNGFDGpLedChkA1AwBhYflrvAX_fag8tUg2WTxuLclyJ4zpyOUP3F72bf7OP5r5YIBKM4QkBYwQm2FmK70RirhU4vC_wzvOTt5weDuu_Dvx74FXaB3YtEPM1c5unS-AAkKLbRyrEsD78Fh8EMp0ZtWSsceqhOOIeDL2iY1_KGk8yT585xvO1id8iNcQUoAggJ2s6qCCPAqg13y5X1_CtvPvEG179h2AJT100D85AtDvYr2LQ","oth":[],"use":"sig","x5c":[]}]

When Public keys are created this can be uploaded in portal

Maskinporten
Setting up client

If you use Azure Keyvault to store your private keys this need to be base 64 encoded before adding it to the secrets

PS C:\keys> altinn-jwks export key testklient --base64
eyJhbGciOiJSUzI1NiIsImQiOiJ2VC1fdldGb1N1c0tQM2p6WmhWRlc0WWthbDV2VTl1VkdGTVBKMkp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ENyX1BrV2hLWmV1TFh0SExJaUFPRGpuV2RzYW5STTN6VE9udyIsInVzZSI6InNpZyIsIng1YyI6W119

Authentication with client

The detailed description on how to authenticate your client with JWT Grant is described here

If you use .Net you might consider our .Net Maskinporten Client.