# Overview

This guide describes how to integrate ID Check OIDC4IA into an application.

> **Preview**
>
> ID Check OIDC4IA is in preview, so it can change. For a stable integration, use [ID Check](https://docs.stoe.no/id-check.md).

ID Check OIDC4IA uses the OpenID Connect for Identity Assurance (OIDC4IA) protocol for identity verification. This section describes how to authenticate the application and use the ID Check OIDC4IA API.

> **Note**
>
> For an overview of the terms used in this documentation, see the [glossary](https://docs.stoe.no/id-check/glossary.md).

## Flow

The merchant's application, the relying party (RP), starts the OIDC4IA flow to verify the identity of an end user. The verification uses document scanning and facial recognition in the BankID app. The RP only sends the user to the authorisation URL. The ID Check web client opens the BankID app or shows a QR code. The user then comes back to the redirect URI of the RP with an authorisation code.

```mermaid
sequenceDiagram
    actor u as End User
    participant rp as Relying Party (merchant app)
    participant web as ID Check web client
    participant bankid as BankID App
    participant idcheck as ID Check OIDC4IA

    rp->>idcheck: 1. POST /par (authorisation request)
    idcheck-->>rp: 2. Return request_uri
    rp->>u: 3. Send the user to the authorisation URL
    alt On a phone
        u->>bankid: 4. The link opens the BankID app, or the web client if the app isn't installed
        u->>bankid: 5. Complete identity verification
        bankid->>idcheck: 6. Request authorisation code
        idcheck-->>bankid: 7. Return authorisation code
        bankid->>rp: 8. Redirect with authorisation code
    else On a computer
        u->>web: 4. The link opens the web client, which shows a QR code
        u->>bankid: 5. Scan the QR code and complete identity verification
        web->>idcheck: 6. Request the redirect when the session ends
        idcheck-->>web: 7. Return the redirect with the authorisation code
        web->>rp: 8. Redirect with authorisation code
    end
    rp->>idcheck: 9. POST /token (exchange code)
    idcheck-->>rp: 10. Return encrypted ID token
    rp->>rp: 11. Decrypt and validate ID token
```

> **Prerequisites**
>
> The merchant needs a `client_id`, and the URL of a JSON Web Key Set (JWKS) with its public keys, registered with ID Check.
> Contact Stø to get started.

## Implementation steps

### 1. Register the client

To integrate with ID Check, the merchant needs:

1. **Client ID** - A unique identifier for the application
2. **Keypair** - An ES256, PS256, or EdDSA keypair for signing JSON Web Tokens (JWTs)
3. **Registered JWKS URL** - The URL of the merchant's JWKS, registered with ID Check. The JWKS holds the public signing key and an RSA public key for the encryption of the ID token
4. **Redirect URI** - A registered callback URL for the application

### 2. Authentication

All requests to ID Check require client authentication using signed JWTs. See [Authentication](https://docs.stoe.no/id-check/oidc4ia/getting-started/authentication.md) for details on:

- Creating client assertion JWTs
- Supported signing algorithms
- JWKS registration

### 3. PAR request

Push the authorisation parameters to ID Check with the pushed authorisation request (PAR) endpoint. See [Implementation guide](https://docs.stoe.no/id-check/oidc4ia/getting-started/implementation.md) for the complete flow, including:

- Building the request object JWT
- Proof Key for Code Exchange (PKCE) setup
- Claims request format

### 4. Token exchange

After the user completes verification, exchange the authorisation code for an ID token. The ID token contains the verified identity claims.

See [ID token](https://docs.stoe.no/id-check/oidc4ia/id-token.md) for details on the token structure and claims.

## Endpoints

In production, the base URL is `https://api.idverify.bankid.no`. The examples on these pages write it as `{base-url}`. The authorisation endpoint has its own host. Read the endpoints from the OpenID configuration, rather than building them from the base URL.

| Endpoint                                       | URL in production                                                 |
| ---------------------------------------------- | ----------------------------------------------------------------- |
| OpenID configuration (discovery)               | `https://api.idverify.bankid.no/.well-known/openid-configuration` |
| Pushed authorisation request (PAR)             | `https://api.idverify.bankid.no/par`                              |
| Authorisation, where the client sends the user | `https://start.idverify.bankid.no/auth`                           |
| Token, to exchange the authorisation code      | `https://api.idverify.bankid.no/token`                            |
| JWKS, the public keys that verify the ID token | `https://api.idverify.bankid.no/jwks`                             |

For detailed API documentation, see the [API reference](https://docs.stoe.no/id-check/oidc4ia/api/openid-configuration.md).
