Authentication API
Before you can request data via a REST call you need to have an authentication token. To get this token you can use one of the tools described on this page.
This document details the API endpoints used for user authentication within the application. These endpoints are crucial for securing access and are typically used before performing actions that modify documents or require user identification. The authentication primarily uses Bearer tokens obtained through the login process.
For more information about v1 check this documentation.
Base URL
For the authentication for v2 this API endpoint is used:
api/v2/auth
Endpoints
The following endpoints are available for Authentication, relative to the Base URL (api/v2/auth
):
URL | HTTP Method | Description |
---|---|---|
/login |
POST | Authenticates a user using credentials (e.g., username/email and password) and returns authentication tokens. Could be gathered using curl as show in Example1 or with REST.call as shown Example 2. |
Examples
This section provides examples for common authentication workflows.
Example 1: User Login
This example shows how to authenticate a user using their email and password to obtain access tokens.
curl -X POST "[Main API Domain]/api/v2/auth/login" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"username": "user@example.com",
"password": "securepassword123"
}'
{
"accessToken": "eyJhbGciOi...",
"refreshToken": "eyJhbGciOi...",
"userId": "string"
}
Example 2: Getting a Bearer Key using REST.call
For most calls, getting an bearer key is the first step. This makes getting this key very important to correctly understand and use.
It is good to note that the return value is still the same as the first example.
Below, you will find information on how to get the key from the current user using REST.call
:
const loginEndpoint = `${API_server}/api/v2/auth/login`;// Fill API_server in with actual server
const loginMethod = 'POST';
const loginHeaders = {
'Content-Type': 'application/json',
'Accept': 'application/json'
};
const loginBody = {
username: 'user', // actual name needs to be entered
password: 'password' // actual password needs to be entered
};
// Call the API using the REST.call function
const authToken = REST.call(loginEndpoint, loginMethod, loginHeaders, loginBody);
console.log(authToken);