title: Taro.authPrivateMessage(option)

sidebar_label: authPrivateMessage

验证私密消息

支持情况:authPrivateMessage - 图1 authPrivateMessage - 图2 authPrivateMessage - 图3

参考文档

类型

  1. (option: Option) => Promise<SuccessCallbackResult>

参数

参数 类型
option Option

Option

参数 类型 必填 说明
shareTicket string shareTicket
success (result: SuccessCallbackResult) => void 接口调用成功的回调函数
fail (res: TaroGeneral.CallbackResult) => void 接口调用失败的回调函数
complete (res: TaroGeneral.CallbackResult) => void 接口调用结束的回调函数(调用成功、失败都会执行)

SuccessCallbackResult

参数 类型 必填 说明
cloudID string 敏感数据对应的云 ID,开通云开发的小程序才会返回,可通过云调用直接获取开放数据,详细见云调用直接获取开放数据
encryptedData string 包括敏感数据在内的完整转发信息的加密数据,详细见加密数据解密算法
errMsg string 错误信息
iv string 加密算法的初始向量,详细见加密数据解密算法

示例代码

  1. Taro.authPrivateMessage({
  2. shareTicket: 'xxxxxx',
  3. success(res) {
  4. console.log('authPrivateMessage success', res)
  5. // res
  6. // {
  7. // errMsg: 'authPrivateMessage:ok'
  8. // valid: true
  9. // iv: 'xxxx',
  10. // encryptedData: 'xxxxxx'
  11. // }
  12. },
  13. fail(res) {
  14. console.log('authPrivateMessage fail', res)
  15. }
  16. })