Introduction


Visual face is a credential that captures the user's face with a visual camera. It is different from face information captured with an infrared camera and is only available on devices that support visual face. 

Currently, FaceStation F2, BioStation 3, BioEntry W3 supports visual face as user credential.


There are 3 different ways to add a visual face credential to a user.


1) Scan your face on a device.

2) Upload an image. 

3) Register via email.


This article will guide you through adding a visual face credential by registering through email via BioStar 2 API. 


This article also includes a sample code of C# program built using the APIs mentioned in this article. You can reference it if you are integrating this functionality via API and need some guidance. 


If you'd like to learn about how to add visual face by other methods via BioStar 2 API, please check out the following articles.

Adding visual face credential by scanning face on a device - [BioStar 2 API] Add Visual Face Credential by Scanning Face on a Device

Adding visual face credential by uploading an image - [BioStar 2 API] Add Visual Face Credential by Uploading an Image  



Prerequisites


1. Cloud Setting must be configured. To configure Cloud Setting, please refer to the article below:

How to configure Cloud and Mobile App


2. Email Setting must be configured. To configure Email Setting, please follow the instructions below: 

       

 a. Go to BioStar 2 > Settings > Email Setting 

텍스트, 전자기기이(가) 표시된 사진

자동 생성된 설명

 

b. Click on 'SMTP setting' and enter appropriate value for SMTP Option. 

For more information on how to configure SMTP, please refer to the article below:

How to Configure SMTP and Test the Recipient Address


c. Enable 'Visual Face Mobile Enrollment' and fill in the additional options (Email Title, Company Name, Company Logo, Contact) if you'd like to have them configured for the email. 

텍스트이(가) 표시된 사진

자동 생성된 설명


d. Go to Users and click on a user you'd like to send the visual face registration email. Fill in the 'Email' of the user. 


 


After you've completed all the prerequisites, you are ready to call the API that will send the registration email to enroll visual face to a user.


[POST]         /api/v2/send_email


[Body Parameters] 

ParameterTypeRequiredDescription
id
StringN
id of user you want to send the registration email (this user must have the 'email' field filled out in their profile
languageString
N
Language in which the email will be written in ("en" for english)


[Example Request Body ]

{

     "id": "2",

     "language": "en"

}

[Postman Example]

 

After you run the API successfully, you'll receive a 200 HTTP status code with a response body that looks like below. 


[Example of Successful Response]

{

  "code": "0"

}

 [Response Body Example] 

 

[Example of Unsuccessful Response] 

{

    "code": "1000"

}


The user with user id that you put in the parameter will now receive an email that looks like below where they can enroll their visual face credential.  




C# Console Application Example  

 

[Sending Email (for Visual Face Registration) Method Source Code] 

static async void EmailVisualFaceReg()

        {

            Console.WriteLine("*****EmailVisualFaceReg Task Started*****");

            CookieContainer cookieContainer = new CookieContainer();

 

            HttpClientHandler handler = new HttpClientHandler();

            handler.CookieContainer = cookieContainer;

 

            HttpClient httpClient = new HttpClient(handler);

 

            HttpClient client = new HttpClient(handler);

               httpClient.DefaultRequestHeaders.Add("bs-session-id", sessionID);

            cookieContainer.Add(new Uri("https://127.0.0.1"), new Cookie("bs-session-id", sessionID));

            ListUsers();

            Console.WriteLine("Select User ID for Visual Face Registration via Email...");

            string userID = Console.ReadLine();

            string resourceAddress = "https://127.0.0.1/api/v2/send_email/";

 

            JavaScriptSerializer serializer = new JavaScriptSerializer();

 

            string payload = "{ \"id\": \"" + userID + "\", \"language\": \"en\"}";

            Console.WriteLine(payload);

            StringContent sc = new StringContent(payload, Encoding.UTF8, "application/json");

            //HttpResponseMessage httpResponse = await httpClient.PostAsync(resourceAddress, sc);

            HttpResponseMessage httpResponse = httpClient.PostAsync(resourceAddress, sc).Result;

 

            if (httpResponse.IsSuccessStatusCode == true)

            {

                Console.WriteLine("Email Sent. Check your Email.");

                string httpResponseBody = await httpResponse.Content.ReadAsStringAsync();

                   Console.WriteLine(httpResponseBody);

            }

            else

            {

                Console.WriteLine("Email Send Failed.");

                   Console.WriteLine(httpResponse.ToString());

            }

        }

 

After Running the Above Code... 

텍스트이(가) 표시된 사진

자동 생성된 설명