1、生物认证
生物认证 是一种基于个体独特生理或行为特征进行身份验证的技术,广泛应用于安全、金融、医疗等领域。
小程序目前暂时只支持指纹识别认证。
2、查询支持的生物认证方式
获取本机支持的 SOTER 生物认证方式,文档
onLoad(options) {
wx.checkIsSupportSoterAuthentication({
success(res) {
console.log(res);
},
fail(err) {
console.log(err)
}
})
}
返回:
{
"supportMode": [
"fingerPrint"
]
}
- fingerPrint,指纹识别
- facial,人脸识别
- speech,声纹识别(暂未支持)
3、检查是否录入生物信息
获取设备内是否录入如指纹等生物信息的接口,文档
onLoad(options) {
wx.checkIsSoterEnrolledInDevice({
checkAuthMode: 'fingerPrint',
success(res) {
console.log(res.isEnrolled)
},
fail(err) {
console.log(err);
}
})
}
返回:
{
"isEnrolled": true,
"errMsg": null
}
- isEnrolled,是否已录入信息
- errMsg,错误信息
4、使用生物认证
开始 SOTER 生物认证,文档
onLoad(options) {
wx.startSoterAuthentication({
requestAuthModes: ['fingerPrint'],
challenge: '123456',
authContent: '请用指纹解锁',
success(res) {
console.log(res);
},
fail(err) {
console.log(err);
}
})
}
- requestAuthModes,请求使用的可接受的生物认证方式
- challenge,挑战因子为调用者为此次生物鉴权准备的用于签名的字符串关键识别信息,将作为 resultJSON 的一部分,供调用者识别本次请求。例如:如果场景为请求用户对某订单进行授权确认,则可以将订单号填入此参数。
- authContent,验证描述,即识别过程中显示在界面上的对话框提示内容
效果:
返回:
{
"authMode": "fingerPrint",
"resultJSON": {},
"resultJSONSignature": "P3jGJOtJNnxnNbw==",
"errCode": 0,
"errMsg": "startSoterAuthentication:ok"
}
如您在阅读中发现不足,欢迎留言!!!