Generate a token
URL
POST https://api.complycube.com/v1/tokens
Generates an SDK token.
Headers
Content-Type*
string
The content-type must always be set to application/json.
Authorization*
string
The API live or test key.
Body
clientId*
string
The ID of the client.
referrer
string
The referrer URI pattern for the Web SDK. You can find more details below. This is only required for the Web SDK.
appId
string
The iOS or Android application or bundle ID. This is only required for the Mobile SDKs.
The referrer attribute
referrer attributeThe referrer attribute specifies the URI of the web page where you will use the Web SDK. The referrer sent by the browser must match the referrer URI pattern in the JWT for the SDK to authenticate successfully.
The referrer is based on the Google Chrome match pattern URIs. URIs can contain wild card characters.
The referrer pattern included in the JWT guarantees that other malicious websites cannot reuse the JWT if it is lost.
Example request for Web SDK
curl -X POST https://api.complycube.com/v1/tokens \
-H 'Authorization: <YOUR_API_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"clientId":"CLIENT_ID",
"referrer": "https://www.example.com/*"
}'const { ComplyCube } = require("@complycube/api");
const complycube = new ComplyCube({ apiKey: "<YOUR_API_KEY>" });
const token = await complycube.token.generate("CLIENT_ID", {
referrer: "https://www.example.com/*"
});from complycube import ComplyCubeClient
cc_api = ComplyCubeClient(api_key='<YOUR_API_KEY>')
token = cc_api.tokens.create('CLIENT_ID', referrer='https://www.example.com/*')use ComplyCube\ComplyCubeClient;
$ccapi = new ComplyCubeClient('<YOUR_API_KEY>');
$token = $ccapi->tokens()->generate('CLIENT_ID', 'https://www.example.com/*');using ComplyCube.Net;
using ComplyCube.Net.Resources.SDKTokens;
var sdkTokenApi = new SDKTokenApi(new ComplyCubeClient("<YOUR_API_KEY>"));
var sdkTokenRequest = {
clientId = "CLIENT_ID",
referrer = "https://www.example.com/*"
}
var sdkToken = await sdkTokenApi.GenerateToken(sdkTokenRequest);Example request for Mobile SDK
curl -X POST https://api.complycube.com/v1/tokens \
-H 'Authorization: <YOUR_API_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"clientId":"CLIENT_ID",
"appId: "com.myapp.demo.app"
}'const { ComplyCube } = require("@complycube/api");
const complycube = new ComplyCube({ apiKey: "<YOUR_API_KEY>" });
const token = await complycube.token.generate("CLIENT_ID", {
appId: "com.myapp.demo.app"
});from complycube import ComplyCubeClient
cc_api = ComplyCubeClient(api_key='<YOUR_API_KEY>')
token = cc_api.tokens.create('CLIENT_ID', appId='com.sample.app')use ComplyCube\ComplyCubeClient;
$ccapi = new ComplyCubeClient('<YOUR_API_KEY>');
$token = $ccapi->tokens()->generate('CLIENT_ID', 'com.sample.app');using ComplyCube.Net;
using ComplyCube.Net.Resources.SDKTokens;
var sdkTokenApi = new SDKTokenApi(new ComplyCubeClient("<YOUR_API_KEY>"));
var sdkTokenRequest = {
clientId = "CLIENT_ID",
appId = "com.sample.app"
}
var sdkToken = await sdkTokenApi.GenerateToken(sdkTokenRequest);Example responses
{
"token": "<CLIENT_TOKEN>"
}{
"type": "invalid_request",
"message": "'clientId' is invalid",
"param": "clientId"
}Last updated
Was this helpful?