Generate Admin Api Token

Overview

To manage sub-accounts, an Admin Token is required. This token is obtained by calling the authentication endpoint with the API key and signature.


Authentication Endpoint - URL

  • Release Candidate (RC): https://sdk-mobile-api-rc.truvideo.com

  • Production: https://sdk-mobile-api.truvideo.com

CURL Example

HTTP Method - POST

Headers

  • x-authentication-api-key: {APIKEY} (Admin key provided by the Truvideo team)

  • x-authentication-signature: {SIGNATURE} (Generated using the secret key)

  • x-multitenant-external-id: {EXTERNAL-ID} (External ID for the sub-account, configured by the Partner. Required for multi-tenant purposes)

  • Content-Type: application/json

Request Body

{
    "timestamp": {TIMESTAMP}
}

Parameters

Parameter

Description

BASE-URL

Base URL of the endpoint.

APIKEY

Admin key provided by the Truvideo team.

EXTERNAL-ID

External ID for the sub-account. Configured by the Partner. Required for multi-tenancy.

SIGNATURE

Signature generated using the secret key (see below for generation details).

TIMESTAMP

Long timestamp in milliseconds. Must not be older than 30 minutes.

Curl Example

curl --location '{BASE-URL}/api/login/session' \
--header 'x-authentication-api-key: {APIKEY}' \
--header 'x-authentication-signature: {SIGNATURE}' \
--header 'x-multitenant-external-id: {EXTERNAL-ID}' \
--header 'Content-Type: application/json' \
--data '{
    "timestamp": {TIMESTAMP}
}'

Response

The response will contain the accessToken field, which is used in subsequent configuration requests.

Example Response

{
    "accessToken": "eyJhbfIWOJnewIUzI1NiJ9.eWIiOiJhZG1pbiIsImV4cCI6MTcyMTEzNjc0MCwiYXV0aCI6IkFETUlOIEJBQ0tPRkZJQ0UiLCJpYXQiOjE3MjEwNTAzNDAsImRldmljZUlkIjoiLTEifQ.bosYs82RrGsqx6we_MFrcebIhh6d5hUMWaecbCiySDU",
    "refreshToken": "eyJhbfIWOJnewIUzI1NiJ9.eiOiJhZG1pbiIsImV4cCI6MTcyMTY1NTE0MCwiYXV0aCI6IkFETUlOIEJBQ0tPRkZJQ0UiLCJpYXQiOjE3MjEwNTAzNDAsImRldmljZUlkIjoiLTEifQ.77odDiZJ7CWjGHM7yNSRU4b8ycqzkPzPwUKXi0aEAOU"
}

Signature Generation

To generate the signature, follow these steps:

Step 1: Generate the Body

The body structure should be:

{
"timestamp": "2024-09-06T05:36:25.966Z"
}

Step 2: Minify the Body

Remove all spaces (whitespace, tabs, etc.) and respect the structure in which the data is sent. For example:

{"timestamp":"2024-09-06T05:36:25.966Z"}

Step 3: Create the Signature

Use the body and the secret key to generate the signature using SHA-256 in hexadecimal format. Below is an example:

For generating signature you can refer - https://www.devglan.com/online-tools/hmac-sha256-online

Notes

  • Ensure the timestamp is in milliseconds and is within the allowable time range (not older than 30 minutes).

  • Always use the exact attribute order as shown in the body example.


Usage

Use the accessToken returned in the response for subsequent configuration or API requests for managing sub-accounts.

For further assistance, please contact the Truvideo support team.

Last updated