Facial authentication (1:1 Authentication) - Rest PKI Core
- Compares the face captured in real time with a previously enrolled biometric, confirming that the user really is who they claim to be.
- The photo is collected through a liveness check.
Creating the session
To create an authentication session, use the StartAuthenticationSessionAsync method of the client libs, passing a
StartBioAuthenticationSessionRequest.
This method makes a POST request to /api/bio/sessions/authentication (Swagger).
Parameters (StartBioAuthenticationSessionRequest)
| Parameter | Required? | Type | Description |
|---|---|---|---|
| ReturnUrl | Conditional* | String | URL to redirect the user to after the biometric check. (see details) |
| TrustedOrigin | Conditional* | String | URL of your site where the widget is embedded. (see details) |
| PlatformPreference | No | Enum | Sets the platform preference and the QR code behavior. (see details) |
| FaceCaptureProvider | No | Enum | Sets the biometric provider. (see details) |
| Subject | Yes | Object | Reference to the user |
*You must pass at least one of the two parameters (see the difference between ReturnUrl and TrustedOrigin):
ReturnUrl(for the redirect flow)TrustedOrigin(for the widget)
Parameters (Subject)
| Parameter | Required? | Type | Description |
|---|---|---|---|
| Id | Conditional* | Guid | Id of the enrollment, generated by Rest PKI Core |
| Identifier | Conditional* | String | External identifier of the user. |
*You must pass at least one of the two parameters:
- (recommended)
Subject.Identifier: use the sameSubjectIdentifierused in the enrollment session. - (advanced)
Subject.Id: if you stored theSubjectId returned by the enrollment session, you can use it here. Beware: if the previous enrollment is deleted, a new enrollment for the sameSubjectIdentifiergets a different Id.
Response example
The request to StartAuthenticationSessionAsync returns the following response:
{
"sessionType": "Authentication",
"sessionId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"sessionUrl": "string"
}
Frontend integration
Once your backend has obtained the sessionUrl from the API, forward it to your frontend. From there, the flow follows the interface you chose:
-
Embedded flow (widget): your application passes the URL to the JavaScript component, which starts the capture inside your page.
-
Redirect flow: your application sends the user to the URL received, where the capture takes place.
If you are unsure how to implement each model, see Frontend flows.
Completing the session
To complete an authentication session, use the CompleteAuthenticationSessionAsync method of the client libs, passing a
CompleteBioSessionRequest.
This method makes a POST request to /api/bio/sessions/authentication/completion (Swagger).
This method is the final step. The ticket can be used only once.
Call the completion only at the end of the process, sending the ticket you received to validate the result and close the session.
Response example
{
"subjectIdentifier": "string",
"subjectId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"failure": "CaptureFailed",
"sessionId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"success": true,
"resultDataAvailable": true
}
- subjectIdentifier: external identifier of the user. (see details)
- subjectId: Id of the enrollment.
- failure: tells whether a failure occurred during the session; see the list of failures below.
- sessionId: Id of the Rest PKI Core session.
- success: whether the authentication session succeeded.
- resultDataAvailable: if
true, you can fetch the photos collected in the session.
Main failures
| Enum | Description |
|---|---|
| CaptureFailed | The image capture could not be finished. It usually happens when the user interrupts it. |
| LivenessFailed | The user did not pass the liveness check: the number of attempts exceeded the limit. |
| NoMatch | Not enough match between the biometric collected and the one previously enrolled. |
| BadImage | The captured image does not have enough quality to be processed. It may be caused by poor lighting, blur, excessive glare or a partially covered face. |
Checking the status
You can check the current state of a session at any time using its sessionId. This is useful to monitor whether the user has started the
session, or whether it has expired, even before it is completed.
Use GetAuthenticationSessionStatusAsync to follow the progress of an active session by its sessionId.
The response of this endpoint is exactly the same as the response example of CompleteAuthenticationSessionAsync.