生物认证 /verifySignature # soter.verifySignature > 本接口应在服务器端调用,详细说明参见[服务端API](https://developers.weixin.qq.com/miniprogram/dev/framework/server-ability/backend-api.html)。 > 本接口支持[云调用](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/openapi/openapi.html)。需开发者工具版本 >= `1.02.1904090`(最新[稳定版下载](https://developers.weixin.qq.com/miniprogram/dev/devtools/stable.html)),`wx-server-sdk` >= `0.4.0` SOTER 生物认证秘钥签名验证 调用方式: - [HTTPS 调用](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/soter/soter.verifySignature.html#method-http) - [云调用](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/soter/soter.verifySignature.html#method-cloud) ## HTTPS 调用 ### 请求地址 ```text POST https://api.weixin.qq.com/cgi-bin/soter/verify_signature?access_token=ACCESS_TOKEN ``` ### 请求参数 | 属性 | 类型 | 默认值 | 必填 | 说明 | | :------------------------------------ | :----- | :----- | :--- | :----------------------------------------------------------- | | access_token / cloudbase_access_token | string | | 是 | [接口调用凭证](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/access-token/auth.getAccessToken.html) | | openid | string | | 是 | 用户 openid | | json_string | string | | 是 | 通过 [wx.startSoterAuthentication](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/soter/wx.startSoterAuthentication.html) 成功回调获得的 resultJSON 字段 | | json_signature | string | | 是 | 通过 [wx.startSoterAuthentication](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/soter/wx.startSoterAuthentication.html) 成功回调获得的 resultJSONSignature 字段 | ### 返回值 ### Object 返回的 JSON 数据包 | 属性 | 类型 | 说明 | | :------ | :------ | :------- | | errmsg | string | 错误信息 | | errcode | number | 错误码 | | is_ok | boolean | 验证结果 | ### 请求示例 ```json { "openid": "$openid", "json_string": "$resultJSON", "json_signature": "$resultJSONSignature" } ``` ## 云调用 > [云调用](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/openapi/openapi.html)是微信云开发提供的在云函数中调用微信开放接口的能力,需要在云函数中通过 `wx-server-sdk` 使用。 ### 接口方法 ```js openapi.soter.verifySignature ``` > 需在 `config.json` 中配置 `soter.verifySignature` API 的权限,[详情](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/openapi/openapi.html#usage-3) ### 请求参数 | 属性 | 类型 | 默认值 | 必填 | 说明 | | :------------ | :----- | :----- | :--- | :----------------------------------------------------------- | | openid | string | | 是 | 用户 openid | | jsonString | string | | 是 | 通过 [wx.startSoterAuthentication](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/soter/wx.startSoterAuthentication.html) 成功回调获得的 resultJSON 字段 | | jsonSignature | string | | 是 | 通过 [wx.startSoterAuthentication](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/soter/wx.startSoterAuthentication.html) 成功回调获得的 resultJSONSignature 字段 | ### 返回值 ### Object 返回的 JSON 数据包 | 属性 | 类型 | 说明 | | :------ | :------ | :------- | | errMsg | string | 错误信息 | | errCode | number | 错误码 | | isOk | boolean | 验证结果 | ### 异常 ### Object 抛出的异常 | 属性 | 类型 | 说明 | | :------ | :----- | :------- | | errMsg | string | 错误信息 | | errCode | number | 错误码 | **errCode 的合法值** | 值 | 说明 | 最低版本 | | :--- | :--- | :------- | | | | | ### 请求示例 ```js const cloud = require('wx-server-sdk') cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV, }) exports.main = async (event, context) => { try { const result = await cloud.openapi.soter.verifySignature({ "openid": '$openid', "jsonString": '$resultJSON', "jsonSignature": '$resultJSONSignature' }) return result } catch (err) { return err } } ```