生物认证秘钥签名验证

生物认证秘钥签名验证

调试工具

接口应在服务器端调用,详细说明参见服务端API

本接口支持云调用。需开发者工具版本 >= 1.02.1904090(最新稳定版下载),wx-server-sdk >= 0.4.0

接口说明

接口英文名

verifySignature

功能描述

该接口用于SOTER 生物认证秘钥签名验证。

调用方式

HTTPS 调用

POST https://api.weixin.qq.com/cgi-bin/soter/verify_signature?access_token=ACCESS_TOKEN 

云调用

  • 出入参和HTTPS调用相同,调用方式可查看云调用说明文档
  • 接口方法为: openapi.soter.verifySignature

请求参数

属性 类型 必填 说明
access_token string 接口调用凭证,该参数为 URL 参数,非 Body 参数。使用access_token
openid string 用户 openid
json_string string 通过 wx.startSoterAuthentication 成功回调获得的 resultJSON 字段
json_signature string 通过 wx.startSoterAuthentication 成功回调获得的 resultJSONSignature 字段

返回参数

属性 类型 说明
is_ok boolean 验证结果

调用示例

示例说明: HTTPS调用

请求数据示例

{
  "openid": "$openid",
  "json_string": "$resultJSON",
  "json_signature": "$resultJSONSignature"
} 

返回数据示例

{
  "errcode": 0,
  "errmsg": "ok",
  "is_ok": true
} 

示例说明: 云函数调用

请求数据示例

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
  }
} 

返回数据示例

{
  "errcode": 0,
  "errmsg": "ok",
  "is_ok": true
} 

错误码

错误码 错误码取值 解决方案
40001 invalid credential access_token isinvalid or not latest 获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口
posted on 2025-01-16 08:38  AtlasLapetos  阅读(14)  评论(0)    收藏  举报