🎉 Unlimited Free KYC - Forever!!

Identity Verification
API Reference
Authentication

Authentication

To interact with the Identity Verification API, you need to authenticate using an access_token. This token is required for all API requests to ensure secure access.

  • Base URL: https://apx.didit.me
  • Endpoint: /auth/v2/token/
  • Method: POST
  • Authentication: Basic Authentication
⚠️

The authentication endpoint uses a different base URL than the verification session endpoints. Ensure you use the correct URLs to avoid connectivity issues.

Request

Follow these steps to obtain an authentication token programmatically:

Step 1: Register Your Application

First, you need to register your application with the Identity Verification service as explained in the Quick Start Guide. This involves obtaining a Client ID and Client secret, which will be used to authenticate your application.

⚠️

Keep your Client ID and Client Secret secure. Never share the Client Secret credentials or expose them in client-side code.

Step 2: Prepare Authentication Parameters

To retrieve the encodedCredentials, follow these steps:

  1. Combine Credentials: Concatenate your Client ID and Client Secret with a colon (:) in between.
  2. Base64 Encode: Encode the combined string using Base64. This encoded string will be used as encodedCredentials.

Include the encodedCredentials in the Authorization header of your request and use the grant type client_credentials.

ParameterTypeRequired?DescriptionExample Value
grant_typestringYesThe OAuth 2.0 grant type to use. Must be set to client_credentials."client_credentials"

Step 3: Send the Request

Make a POST request to /auth/v2/token/ with the prepared parameters.

Example Request

POST /auth/v2/token/ HTTP/1.1
Host: apx.didit.me
Content-Type: application/x-www-form-urlencoded
Authorization: Basic ${encodedCredentials}
 
grant_type=client_credentials

Response

Upon successful authentication, the server responds with a JSON object containing the access token and related information.

Example Response

{
  "iss": "https://didit.me",
  "iat": 1617220000,
  "sub": "your-application-uuid",
  "client_id": "your-client-id",
  "organization_id": "your-organization-id",
  "expires_in": 86400,
  "exp": 1618084000,
  "access_token": "your-client-access-token"
}

Response Fields

FieldTypeDescription
issstringIssuer of the token.
iatnumberTimestamp when the token was issued (Unix timestamp).
substringSubject of the token (your application UUID).
client_idstringYour application's client ID.
organization_idstringYour organization's ID in the system.
expires_innumberToken validity period in seconds (typically 24 hours or 86400 seconds).
expnumberTimestamp when the token will expire (Unix timestamp).
access_tokenstringThe access token to use in subsequent API requests.

Error Handling

Status CodeErrorDescription
401UnauthorizedInvalid client credentials or incorrect encoding format.
400Bad RequestMissing or invalid grant_type parameter.

Example Error Response

{
  "detail": "Invalid authorization header"
}

Token Usage

  • The access_token is valid for 24 hours (86400 seconds)
  • Include it in the Authorization header as a Bearer token for all API requests
  • Store the token securely and refresh it before expiration

For production systems, implement token caching to avoid unnecessary authentication requests.

Code Examples

const fetchClientToken = async () => {
  const url = 'https://apx.didit.me/auth/v2/token/';
  const clientID = process.env.DIDIT_CLIENT_ID;
  const clientSecret = process.env.DIDIT_CLIENT_SECRET;
 
  const encodedCredentials = Buffer.from(
    `${clientID}:${clientSecret}`,
  ).toString('base64');
 
  const params = new URLSearchParams();
  params.append('grant_type', 'client_credentials');
 
  try {
    const response = await fetch(url, {
      method: 'POST',
      headers: {
        Authorization: `Basic ${encodedCredentials}`,
        'Content-Type': 'application/x-www-form-urlencoded',
      },
      body: params,
    });
 
    const data = await response.json();
 
    if (response.ok) {
      return data;
    } else {
      console.error('Error fetching client token:', data.error_description || data.message);
      return null;
    }
  } catch (error) {
    console.error('Network error:', error);
    return null;
  }
};
import base64
import requests
 
def get_client_token():
    url = "https://apx.didit.me/auth/v2/token/"
    client_id = "YOUR_CLIENT_ID"
    client_secret = "YOUR_CLIENT_SECRET"
 
    # Create the encoded credentials
    credentials = f"{client_id}:{client_secret}"
    encoded_credentials = base64.b64encode(credentials.encode('utf-8')).decode('utf-8')
 
    headers = {
        'Authorization': f'Basic {encoded_credentials}',
        'Content-Type': 'application/x-www-form-urlencoded'
    }
 
    data = {
        'grant_type': 'client_credentials'
    }
 
    try:
        response = requests.post(url, headers=headers, data=data)
        response.raise_for_status()
        return response.json()
    except requests.RequestException as e:
        print(f"Error fetching token: {e}")
        return None