SmartSelfie™ Authentication
Required Class: WebApi Class

Running SmartSelfie™ Authentication on Python

  1. 1.
    Get your Smile Identity Partner ID
  2. 2.
    Get your Base64 encoded API Key
  3. 3.
    Create a Callback Endpoint
  4. 4.
    Get your User's Selfie & ID Card images
  5. 5.
    Get the user ID you initially used to register the user
  6. 6.
    Submit the Job to Smile Identity
  7. 7.
    Interpret your results

Get your Partner ID

You can find your Partner ID in the developer section of the portal.

Get your Base64 encoded API Key

Your encoded API Key is also in the developer section of the portal.
  • Click on the Generate New API Key button
  • Copy your encoded API Key
Generate a new API Key
Copy your encoded API Key

Create a Callback Endpoint

Responses from this product are asynchronous (based on various actions we carry out on the product) and are sent as soon as they are ready, you will need to setup a callback when submitting a job. You can read about creating a Callback URL here.

Get the User's Selfie

To successfully run SmartSelfie™ Authentication jobs you need to submit the user's selfie. There are two types of selfies that can be submitted
  • Selfie - a single colour-image selfie of user
  • (optional but required for Proof of Live) Liveness images - 7 to 9 greyscale images of user
  • ID card photo
The selfies images can either be submitted as files (with the path to the image specified during submission) or as base64 encoded strings.
We recommend that you use our Web SDK to capture these images.

Get the User's User ID

Since SmartSelfie™ Authentication entails comparing a user's selfie with the selfie they have on file in Smile Identity, you must supply the User's existing user_id in the partner params (the user_id must be the same as the one you used when you ran a successful "Enhanced KYC + SmartSelfie™" or "Document Verification" for the user). If the User ID you supplied does not exist, the job will fail.

Submit the Job to Smile Identity

submit_job method
Copy this code and replace sections marked with <>
1
#import the WebApi module
2
from smile_id_core import WebApi
3
4
partner_id = "<Put your 3 digit partner ID here>"
5
default_callback = "<Put your default callback url here>"
6
api_key = "<Put your base64 encoded API key here>" # Download your API key from the Smile Identity portal
7
sid_server = "<0 | 1>" # Use '0' for the sandbox (test) server, use '1' for production server
8
9
# Initialize
10
try:
11
connection = WebApi(partner_id, default_callback, api_key, sid_server)
12
except ValueError:
13
# some of your params entered for a job are not valid or missing
14
print("handle ValueError")
15
16
# Create required tracking parameters
17
partner_params = {
18
"user_id": '<put your unique ID for the user here>',
19
"job_id": '<put unique job name here>',
20
"job_type": "2"
21
}
22
23
# Create image list
24
# image_type_id
25
# 0 - Selfie image in jpg or png format
26
# 2 - Selfie image in jpg or png base64 encoded string format
27
# 4 - Liveness image in jpg or png format
28
# 6 - Liveness image in jpg or png base64 encoded string format
29
image_details = [
30
{
31
"image_type_id": "<0 | 2>",
32
"image": "<path to selfie image or base64 image string>"
33
},
34
# Not required if you don't require proof of life
35
{
36
"image_type_id": "<4 | 6>",
37
"image": '<path to liveness image or base64 image string>'
38
}
39
]
40
41
# Create ID number info
42
id_info = {
43
"first_name": '<name>',
44
"last_name": '<surname>',
45
"country": '<country code>',
46
"id_type": '<id type>',
47
"dob": '<date of birth>', # yyyy-mm-dd
48
"id_number": '<valid id number>',
49
"entered": '<True | False>' # must be a string
50
}
51
52
# Create options
53
options = {
54
"return_job_status": "< True | False >",
55
"return_history": "< True | False >",
56
"return_image_links": "< True | False >"
57
}
58
59
try:
60
response = connection.submit_job(partner_params, image_details, none, options)
61
except ValueError:
62
# some of your params entered for a job are not valid or missing
63
print("handle ValueError")
64
except ServerError:
65
# Server returned an error
66
print("handle ServerError")
67
except FileNotFoundError:
68
# Sent a file which could not be found
69
print("handle FileNotFoundError")
Copied!
NOTE: The response will be a python object. If you do not need to pass through options, you may omit calling those class and send through None in submit_job, as follows:
1
response = connection.submit_job(partner_params, image_details, None, None)
Copied!
If an error occurs, the Web Api package will throw an error. Be sure to catch any error that occurs as in this example:
1
try:
2
response = connection.submit_job(partner_params, image_params, id_info_params, options_params)
3
except ValueError:
4
# some of your params entered for a job are not valid or missing
5
print("handle ValueError")
6
except ServerError:
7
# Server returned an error
8
print("handle ServerError")
9
except FileNotFoundError:
10
# Sent a file which could not be found
11
print("handle FileNotFoundError")
Copied!

API Response

Should you choose to set return_job_status to false, the response will be a JSON String containing:
1
{"success": True, "smile_job_id": "<smile_job_id>"}
Copied!
However, if you have set return_job_status to true (with image_links and history) then you will receive JSON Object response like below:
1
{
2
"job_success":true,
3
"result":{
4
"ConfidenceValue":"99",
5
"JSONVersion":"1.0.0",
6
"Actions":{
7
"Human_Review_Compare": "Not Applicable",
8
"Human_Review_Liveness_Check": "Passed",
9
"Human_Review_Update_Selfie": "Not Applicable",
10
"Liveness_Check": "Passed",
11
"Register_Selfie": "Not Applicable",
12
"Return_Personal_Info": "Not Applicable",
13
"Selfie_Provided": "Passed",
14
"Selfie_To_ID_Authority_Compare": "Not Applicable",
15
"Selfie_To_ID_Card_Compare": "Not Applicable",
16
"Selfie_To_Registered_Selfie_Compare": "Completed",
17
"Update_Registered_Selfie_On_File": "Not Applicable",
18
"Verify_ID_Number": "Not Applicable"
19
},
20
"ResultText":"Authenticated",
21
"IsFinalResult":"true",
22
"IsMachineResult":"true",
23
"ResultType":"SAIA",
24
"PartnerParams":{
25
"job_type":"2",
26
"optional_info":"we are one",
27
"user_id":"HBBBBBBH57g",
28
"job_id":"HBBBBBBHg"
29
},
30
"Source":"WebAPI",
31
"ResultCode":"1220",
32
"SmileJobID":"0000001111"
33
},
34
"code":"2302",
35
"job_complete":true,
36
"signature":"...",
37
"history":[
38
{
39
"ConfidenceValue":"99",
40
"JSONVersion":"1.0.0",
41
"Actions":{
42
"Human_Review_Compare": "Not Applicable",
43
"Human_Review_Liveness_Check": "Passed",
44
"Human_Review_Update_Selfie": "Not Applicable",
45
"Liveness_Check": "Passed",
46
"Register_Selfie": "Not Applicable",
47
"Return_Personal_Info": "Not Applicable",
48
"Selfie_Provided": "Passed",
49
"Selfie_To_ID_Authority_Compare": "Not Applicable",
50
"Selfie_To_ID_Card_Compare": "Not Applicable",
51
"Selfie_To_Registered_Selfie_Compare": "Completed",
52
"Update_Registered_Selfie_On_File": "Not Applicable",
53
"Verify_ID_Number": "Not Applicable"
54
},
55
"ResultText":"Authenticated",
56
"IsFinalResult":"true",
57
"IsMachineResult":"true",
58
"ResultType":"SAIA",
59
"PartnerParams":{
60
"job_type":"2",
61
"optional_info":"we are one",
62
"user_id":"HBBBBBBH57g",
63
"job_id":"HBBBBBBHg"
64
},
65
"Source":"WebAPI",
66
"ResultCode":"1220",
67
"SmileJobID":"0000001111"
68
}
69
],
70
"image_links":{
71
"selfie_image":"image_link"
72
},
73
"timestamp":"2019-10-10T12:32:04.622Z"
74
}
Copied!
You can also view your response asynchronously at the callback that you have set, it will look as follows:
1
{
2
"job_success":true,
3
"result":{
4
"ConfidenceValue":"99",
5
"JSONVersion":"1.0.0",
6
"Actions":{
7
"Human_Review_Compare": "Not Applicable",
8
"Human_Review_Liveness_Check": "Passed",
9
"Human_Review_Update_Selfie": "Not Applicable",
10
"Liveness_Check": "Passed",
11
"Register_Selfie": "Not Applicable",
12
"Return_Personal_Info": "Not Applicable",
13
"Selfie_Provided": "Passed",
14
"Selfie_To_ID_Authority_Compare": "Not Applicable",
15
"Selfie_To_ID_Card_Compare": "Not Applicable",
16
"Selfie_To_Registered_Selfie_Compare": "Completed",
17
"Update_Registered_Selfie_On_File": "Not Applicable",
18
"Verify_ID_Number": "Not Applicable"
19
},
20
"ResultText":"Authenticated",
21
"IsFinalResult":"true",
22
"IsMachineResult":"true",
23
"ResultType":"SAIA",
24
"PartnerParams":{
25
"job_type":"2",
26
"optional_info":"we are one",
27
"user_id":"HBBBBBBH57g",
28
"job_id":"HBBBBBBHg"
29
},
30
"Source":"WebAPI",
31
"ResultCode":"1220",
32
"SmileJobID":"0000001111"
33
},
34
"code":"2302",
35
"job_complete":true,
36
"signature":"...",
37
"history":[
38
{
39
"ConfidenceValue":"99",
40
"JSONVersion":"1.0.0",
41
"Actions":{
42
"Human_Review_Compare": "Not Applicable",
43
"Human_Review_Liveness_Check": "Passed",
44
"Human_Review_Update_Selfie": "Not Applicable",
45
"Liveness_Check": "Passed",
46
"Register_Selfie": "Not Applicable",
47
"Return_Personal_Info": "Not Applicable",
48
"Selfie_Provided": "Passed",
49
"Selfie_To_ID_Authority_Compare": "Not Applicable",
50
"Selfie_To_ID_Card_Compare": "Not Applicable",
51
"Selfie_To_Registered_Selfie_Compare": "Completed",
52
"Update_Registered_Selfie_On_File": "Not Applicable",
53
"Verify_ID_Number": "Not Applicable"
54
},
55
"ResultText":"Authenticated",
56
"IsFinalResult":"true",
57
"IsMachineResult":"true",
58
"ResultType":"SAIA",
59
"PartnerParams":{
60
"job_type":"2",
61
"optional_info":"we are one",
62
"user_id":"HBBBBBBH57g",
63
"job_id":"HBBBBBBHg"
64
},
65
"Source":"WebAPI",
66
"ResultCode":"1220",
67
"SmileJobID":"0000001111"
68
}
69
],
70
"image_links":{
71
"selfie_image":"image_link"
72
},
73
"timestamp":"2019-10-10T12:32:04.622Z"
74
}
Copied!

Interpret your Results

You can read more about result codes and responses in the SmartSelfie™ Authentication section of the docs.
Last modified 4mo ago