API Service Tokens
To call protected LoginID API endpoints, developers need to authenticate with an access token called the API service token. These tokens are JSON Web Tokens (JWTs) which contain specific grant permissions known as scopes. These tokens are signed by the API Credential Private Key
which has been assigned to the integration.
This is similar to the credentials you would create with Google to use Google authentication. This allows you to use LoginID services in a secure, authenticated fashion.
#
Prerequisites- Existing admin / developer account (i.e. access to the dashboard)
- A backend - private keys cannot be stored on a front end only application
#
Initial API Credential SetupTo set up an API credential, you will need to perform the following steps:
Navigate to the Integrations section in the dashboard
Choose the "New API Credential" option to create a new API credential
- This generates a public private key pair. We only store the public key and use it to validate signed requests from you.
Assign the newly created API credential to an existing integration
Copy the API Private Key and use it to fill the
API_PRIVATE_KEY
variable:
note
API_PRIVATE_KEY
has to be entered as a single line string with all newlines replaced with \n character.
#
Create an API Service TokenThe easiest way to generate an API Service Token is to use one of our Server SDKs. Our SDKs automatically create the appropriate token on your behalf, simplifying the flow. If using a server SDK does not suite your needs, you can continue below to understand how to generate a service token yourself.
An API service token has to be signed by the API Credential Private Key and added to request headers as the Authorization: Bearer <token>
header.
#
Required Token Payloadnote
The username
field is only required if the username
is included in the request payload.
#
Required Token HeaderOnce the token is created, it must be signed with the ES256 algorithm using the API_CREDENTIAL_PRIVATE_KEY
.
#
How to find out which scope is required?To see the required scope for each endpoint, please refer to the documentation for the respective flows. Below is a list of some of the endpoints and their respective scopes.
Endpoint | Required | Scope |
---|---|---|
POST /register/fido2/init | Optional | auth.register |
POST /register/password | Optional | auth.register |
POST /authenticate/fido2/init | Optional | auth.login |
POST /authenticate/password | Optional | auth.login |
POST /codes/{type}/generate | Yes | codes.generate |
POST /codes/{type}/authorize | Yes | codes.authorize |
POST /codes/{type}/invalidate-all | Yes | codes.invalidate |
GET /credentials | Yes | credentials.list |
POST /credentials/rename | Yes | credentials.rename |
POST /credentials/revoke | Yes | credentials.revoke |
POST /credentials/fido2/init/code | Optional | credentials.add |
POST /credentials/fido2/init/force | Yes | credentials.force |
POST /manage/users | Yes | users.create |
POST /manage/users/retrieve | Yes | users.retrieve |
POST /manage/users/delete | Yes | users.delete |
DELETE /manage/users/{user_id} | Yes | users.delete |
PUT /manage/users/{user_id}/activate | Yes | users.activate |
PUT /manage/users/{user_id}/deactivate | Yes | users.deactivate |
POST /tx | Yes | tx.create |
POST /tx/init | Optional | tx.create |
#
Token security and lifetimeThe API service token is a short-lived token which expires in 5 minutes. Each token must contain a nonce value which ensures that it is expired once the request is sent. The same token cannot be used to make a new request. A new token must be created when a new request is made.