FaceSessionClient.CreateLivenessSession Method

Definition

Overloads

CreateLivenessSession(CreateLivenessSessionContent, CancellationToken)

Create a new detect liveness session.

CreateLivenessSession(RequestContent, RequestContext)

[Protocol Method] Create a new detect liveness session.

CreateLivenessSession(CreateLivenessSessionContent, CancellationToken)

Source:
FaceSessionClient.cs

Create a new detect liveness session.

public virtual Azure.Response<Azure.AI.Vision.Face.CreateLivenessSessionResult> CreateLivenessSession (Azure.AI.Vision.Face.CreateLivenessSessionContent body, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateLivenessSession : Azure.AI.Vision.Face.CreateLivenessSessionContent * System.Threading.CancellationToken -> Azure.Response<Azure.AI.Vision.Face.CreateLivenessSessionResult>
override this.CreateLivenessSession : Azure.AI.Vision.Face.CreateLivenessSessionContent * System.Threading.CancellationToken -> Azure.Response<Azure.AI.Vision.Face.CreateLivenessSessionResult>
Public Overridable Function CreateLivenessSession (body As CreateLivenessSessionContent, Optional cancellationToken As CancellationToken = Nothing) As Response(Of CreateLivenessSessionResult)

Parameters

body
CreateLivenessSessionContent

Body parameter.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

body is null.

Examples

This sample shows how to call CreateLivenessSession.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
FaceSessionClient client = new FaceSessionClient(endpoint, credential);

CreateLivenessSessionContent body = new CreateLivenessSessionContent(LivenessOperationMode.Passive)
{
    SendResultsToClient = true,
    DeviceCorrelationIdSetInClient = true,
    DeviceCorrelationId = "your_device_correlation_id",
    AuthTokenTimeToLiveInSeconds = 60,
};
Response<CreateLivenessSessionResult> response = client.CreateLivenessSession(body);

Remarks

Please refer to https://video2.skills-academy.com/rest/api/face/liveness-session-operations/create-liveness-session for more details.

Applies to

CreateLivenessSession(RequestContent, RequestContext)

Source:
FaceSessionClient.cs

[Protocol Method] Create a new detect liveness session.

public virtual Azure.Response CreateLivenessSession (Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member CreateLivenessSession : Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
override this.CreateLivenessSession : Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
Public Overridable Function CreateLivenessSession (content As RequestContent, Optional context As RequestContext = Nothing) As Response

Parameters

content
RequestContent

The content to send as the body of the request.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The response returned from the service.

Exceptions

content is null.

Service returned a non-success status code.

Examples

This sample shows how to call CreateLivenessSession and parse the result.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
FaceSessionClient client = new FaceSessionClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    livenessOperationMode = "Passive",
    sendResultsToClient = true,
    deviceCorrelationIdSetInClient = true,
    deviceCorrelationId = "your_device_correlation_id",
    authTokenTimeToLiveInSeconds = 60,
});
Response response = client.CreateLivenessSession(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("sessionId").ToString());
Console.WriteLine(result.GetProperty("authToken").ToString());

Applies to