API Authentication
This document will cover the steps required to send API requests using Yoti’s new Central Auth.
Proof of Age Scope
All API calls will be made using an OAuth Access Token as a bearer token.
The required steps to generate this Access Token and make API calls to Yoti are as follows:
Generate a JWT token using a Yoti private key (.pem file)
Acquire an OAuth Access Token using this JWT Token
Send an API request to Yoti
A token can be reused for multiple requests - you must NOT use a new token for every request. There is a limit of 200 active tokens per service/SDK ID. We advise that you use one key for all calls within a scope and obtain a new token every 30 minutes.
You will need a Verified Yoti Organisation account and service set up with a Private PEM key and SDK ID.
Generating a JWT Token
We use the private_key_JWT client authentication method from OIDC Core. The JWT will be signed by the RSA private key of the service/SDK ID that you are authenticating as.
Header | Value | Description |
|---|---|---|
alg | PS384 | Algorithm. We require the algorithm to be PS384. No other algorithms are accepted. |
typ | JWT | Type. Must be the string value JWT. |
The following claims must be present in the payload:
Claim | Value | Description |
|---|---|---|
iss | sdk: <YOUR_SDK_ID> | Issuer. Must be set to the string “sdk:" || SDK ID, e.g. sdk:67d60fe2-5576-49ae-9ac9-ad76b232c5e1. |
sub | sdk: <YOUR_SDK_ID> | Subject. Must be set to the same value as iss |
aud | Audience. This must be the full URL for the OAuth client credentials grant endpoint. | |
jti | UUID string | JWT ID. We require a valid UTF-8 string of at least 16 bytes and at most 128 bytes (not characters) in length. Each JWT that is issued must use a different jti value; the authorisation server will remember iss || jti |
exp | 1751700000 | Expiry time. The authorisation server will refuse to grant client credentials if a request is processed after this time. The expiry time can be a maximum of 30 minutes in the future. |
iat | 1751700000 | OPTIONAL. Issued at. The authorisation server will refuse to grant client credentials if this value is unreasonably far in the past. We have a threshold of 30 minutes |
nbf | 1751700000 | OPTIONAL. Not before. The authorisation server will refuse to grant client credentials if the request arrives before the “not before” time. |
Examples
Response
OAuth Token Grant
Once you have generated a JWT token, you can use it to request an OAuth Access Token for Yoti API calls.
You must request this from the Yoti authorisation server. The request method is POST, and the body from the client must be encoded with the application/x-www-form-urlencoded content type
The request must include the following form values:
Header | Value | Description |
|---|---|---|
grant_type | client_credentials | OAuth grant type |
scope | <your_scope> - string | A space-separated list of one or more scopes that the token will grant access for. |
client_assertion_type | urn:ietf:params:oauth:client-assertion-type:jwt-bearer | The OAuth client assertion type |
client_assertion | JWT value | The value of the JWT token |
comment | “production_key” | Must be valid UTF-8, limited to 128 characters, and comprise only Unicode printable characters. |
Examples
Response
Errors
Due to the OAuth RFC, we will only return 400 or 403 error codes. Details of the error will be found in the response.
Error Code | Details |
|---|---|
400 | Bad Request |
403 | Forbidden |
SDKs
Methods have been added to the Yoti SDKs to generate the Access Tokens instead of the steps above.
Got a question? Contact us here.