Skip to main content

Verify Custom Face

Use the verifyCustomFace() method to run a verification against a source image you already have, rather than against a government-issued ID lookup. The individual completes a liveness session and their captured face is matched against the source image you provide.

1. Creating a Metric instance​

The Metric() constructor is used to create a Metric instance

const metric = new window.Metric({
client_id: "your_public_key",
client_secret: "your_secret_key",
});

Parameters​

client_id: An API encrypted public key string. For example, AIzaSyDaGmWKa4JsXZ-HjGw7ISLn_3namBGewQe


client_secret: An API encrypted secret key string. For example, AIzaSyDaGmWKa4JsXZ-HjGw7ISLn_3namBGewQe


2. Triggering a verification procedure​

The verifyCustomFace() method on the Metric object is called with three arguments: payload, callback, and options(optional). This creates an iframe element that loads the verification process. Once the verification process is complete, the iframe is removed from the DOM and the callback function is called with the results of the verification process.

const metric = new window.Metric({
client_id: "your_public_key",
client_secret: "your_secret_key",
});

metric.verifyCustomFace(payload, callback, options);

Parameters​

payload: An object that contains the data required to perform the verification. The object has the following properties:

  • source_image: A base64-encoded string of the source face image to match against.

  • reference_id: A string representing the reference ID for the verification.

  • purpose (optional): A string representing the purpose of the verification.

callback: A function that takes a single argument results. The function will be called when the verification is complete, and results will contain a status property describing the outcome of the verification.


options(optional): This object provides options for fine-tuning the verification process. This is entirely optional β€” if omitted, the individual is taken through the standard guideline and confirmation screens before the verification begins. If desired, it can contain the following property:

  • section: Determines how the verification session starts. Include either of the following values:

    • "camera" β€” starts the verification directly on the camera screen, skipping the guideline and confirmation screens and proceeding straight to the liveness capture session.

    • "qr" β€” starts the verification in QR-code mode. A QR code is displayed for the individual to scan with a secondary device (such as a mobile phone) in order to continue the verification there.

Full Example​

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Page Title</title>
</head>
<body>
<button onclick="verifyUser()">Verify Me</button>

<script type="text/javascript" src="https://sdk.dev.metric.africa/v1"></script>

<script>
const verifyUser = () => {
const metric = new window.Metric({
client_id: "XXXXXXXXXX",
client_secret: "XXXXXXXXXX",
});

metric.verifyCustomFace(
{
source_image: "data:image/jpeg;base64,/9j/4AAQSkZJRg...",
reference_id: "0300000000",
purpose: "state your purpose",
},
(results) => {
console.log(results.status);
},
{
section: "camera",
}
);
};
</script>
</body>
</html>