This topic describes how to integrate ID Verification - Know Your Customer (KYC) SDK for Node.js for the server-side-only solution of face verification and how to call the FaceCompare operation by using the SDK.
Prerequisites
Node.js 8.0 or later is installed.
Install the SDK
For more information about the source code of ID Verification - KYC SDK for Node.js, see Alibaba Cloud Cloudauth-intl SDK for NodeJS.
We recommend that you use npm to manage dependencies.
npm install @alicloud/openapi-client
npm install @alicloud/cloudauth-intl20220809@1.0.12
Call examples
const { Config } = require("@alicloud/openapi-client");
const CloudAuth = require("@alicloud/cloudauth-intl20220809");
const Client = CloudAuth.default;
async function main() {
// Build client
const config = new Config({
accessKeyId: "your accessKeyId",
accessKeySecret: "your accessKeySecret",
endpoint: "cloudauth-intl.cn-hongkong.aliyuncs.com"
});
const client = new Client(config);
// Build request
const request = new CloudAuth.FaceCompareRequest({
//set sourceFacePicture or sourceFacePictureUrl
sourceFacePicture : "base64 string",
sourceFacePictureUrl : "https://***",
//set targetFacePicture or targetFacePictureUrl
targetFacePicture : "base64 string",
targetFacePictureUrl : "https://***",
merchantBizId : "e0c34a77f5ac40a5aa5e6ed20c35****"
});
// Invoke API
const response = await client.faceCompare(request);
// Get result
console.log(response.body.requestId);
console.log(response.body.result.transactionId);
console.log(response.body.result.passed);
console.log(response.body.result.subCode);
}
main().then(function (response) {});