API Integration
You can use this API to create new sessions or get existing session link
Generate hmac signature
const crypto = require('crypto');
const generateHmac = (httpMethod, url, body, contentType, xAuthClient, secretKey) => {
const requestUrl = new URL(url);
const requestPath = requestUrl.pathname;
const queryParams = requestUrl.searchParams.toString();
const dataToHash = `${httpMethod}\n${requestPath}\n${queryParams}\n${xAuthClient}\n${contentType}\n${body}`;
const hmac = crypto.createHmac('sha256', secretKey);
hmac.update(dataToHash);
return hmac.digest('hex');
};
let httpMethod = "POST";
const url = "https://start.faceverify.ai/api/v1/session";
const body = JSON.stringify({
country: country,
uniqueIdentifier,
});
const contentType = "application/json";
//xAuthClient is your apiKey
const xAuthClient = "xxx-xxx-xxx-xxx-xxx"
const secretKey = "xxx-xxx-xxx-xxx-xxx";
const hmacSignature = generateHmac(httpMethod,url,body,contentType,xAuthClient,secretKey);
console.log(hmacSignature);
import hashlib
import hmac
from urllib.parse import urlparse
def generate_hmac(http_method, url, body, content_type, x_auth_client, secret_key):
parsed_url = urlparse(url)
request_path = parsed_url.path
query_params = parsed_url.query
data_to_hash = f"{http_method}\n{request_path}\n{query_params}\n{x_auth_client}\n{content_type}\n{body}"
hmac_signature = hmac.new(secret_key.encode('utf-8'), data_to_hash.encode('utf-8'), hashlib.sha256).hexdigest()
return hmac_signature
http_method = "POST"
url = "https://start.faceverify.ai/api/v1/session"
body = '{"country": "US", "uniqueIdentifier": "user123"}'
content_type = "application/json"
x_auth_client = "xxx-xxx-xxx-xxx-xxx" # Your API key
secret_key = "xxx-xxx-xxx-xxx-xxx" # Your secret key
hmac_signature = generate_hmac(http_method, url, body, content_type, x_auth_client, secret_key)
print(hmac_signature)
<?php
function generateHmac($httpMethod, $url, $body, $contentType, $xAuthClient, $secretKey) {
$parsedUrl = parse_url($url);
$requestPath = $parsedUrl['path'];
$queryParams = isset($parsedUrl['query']) ? $parsedUrl['query'] : '';
$dataToHash = $httpMethod . "\n" . $requestPath . "\n" . $queryParams . "\n" . $xAuthClient . "\n" . $contentType . "\n" . $body;
$hmacSignature = hash_hmac('sha256', $dataToHash, $secretKey);
return $hmacSignature;
}
$httpMethod = "POST";
$url = "https://start.faceverify.ai/api/v1/session";
$body = json_encode(array(
'country' => 'US',
'uniqueIdentifier' => 'user123'
));
$contentType = "application/json";
// $xAuthClient is your API key
$xAuthClient = "xxx-xxx-xxx-xxx-xxx";
$secretKey = "xxx-xxx-xxx-xxx-xxx"; // Your secret key
$hmacSignature = generateHmac($httpMethod, $url, $body, $contentType, $xAuthClient, $secretKey);
echo $hmacSignature;
?>
Last updated