Preface : Access the face core APP when , It needs to involve the development of multiple back-end interfaces , but The official website document of the human face core There is no complete code example , This article provides an example based on Python A complete example of the server of .
Backend involves 5 Interface ;App It's relatively simple , Use the order number obtained from the back end 、 Signature and other information call SDK that will do .
Server side
Serial number
Content
remarks
1
Time acquisition Access Token
Interface document
2
according to Access Token obtain sign ticket
Interface document
3
The partner sends the identity information to the background : Based on user information and sign ticket Generated signature , obtain faceId( Unique identification of the user who brushes the face ) Wait to start SDK Parameters of
Interface document
4
according to Access Token obtain nonce ticket, Generate sign
Interface document
5
Provide a web Service supply APP The client obtains the above 3、4 The call generated in step SDK Parameters of
6
Server verification results
Interface document
APP End
Serial number
Content
remarks
1
launch http Request to obtain the signature and other parameters generated by the server
2
Start the kernel using the request parameters obtained by the server SDK
Interface document
App For example, please refer to this article : Face nucleus APP Access -Android Server-side implementation
The period of validity 2 Hours , Suggest every 20 Minutes to request new , The coexistence of the old and the new 1 minute .
Use scenarios : obtain sign ticket.
The period of validity 60 minute , Recommendations and Access Token Bind refresh .
Use scenarios : The partner sends the identity information to the background .
The period of validity 120 second , One time .
Use scenarios : start-up SDK face scan .
Refer to the compressed package README file
Dependency Library :
Flask、requests
Usage mode :
1、 stay config.py Fill in the wbappid、secret
Console address :https://console.cloud.tencent.com/faceid/access
2、 Background operation flush_access_token.py
Refresh regularly access_token and sign_ticket.
( Recommended order :nohup python -u flush_access_token.py > flush_access_token.log 2>&1 &)
3、 function web_server.py start-up 2 individual web service :
http://xxx/get_face_params for APP The client gets the order signature and so on SDK Parameters of
http://xxx/get_result Used to obtain validation results
( Recommended order :nohup python -u web_server.py > web_server.log 2>&1 &)
web Detailed description of the service :
function web_server.py after , Console or log The file will print web Service address
Client request protocol : The request method is POST, Request header Content-Type Need to be ‘application/x-www-form-urlencoded’
http://xxx/get_face_params Example of service input :{'name': ' Xiao Ming ', 'id_no': '4311120022232323'}
http://xxx/get_result Example of service input :{'order_no': 'xxxx'}