From bcece21c276e39e3dc3dc0a0a9cf64006bcad17c Mon Sep 17 00:00:00 2001 From: handongxun Date: Wed, 17 Aug 2022 11:38:55 +0800 Subject: [PATCH] =?UTF-8?q?uni-open-bridge:=20=E6=9B=B4=E6=96=B0=E7=AE=80?= =?UTF-8?q?=E5=8D=95=E8=B0=83=E7=94=A8get=E6=96=B9=E6=B3=95=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/uniCloud/uni-open-bridge.md | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/uniCloud/uni-open-bridge.md b/docs/uniCloud/uni-open-bridge.md index ad31c7ff4..85502e12e 100644 --- a/docs/uniCloud/uni-open-bridge.md +++ b/docs/uniCloud/uni-open-bridge.md @@ -132,21 +132,29 @@ 如果用户没有开通 `redis` 或者操作失败,透传到 `database`,`database` 失败后,如果用户配置了 `fallback`,继续调用 `fallback` 方法,否则抛出 `Error`,`database` 对应的表为: `opendb-open-data` 在常见的情况下,在你的云函数/云对象中调用`uni-open-bridge-common`的几个get方法即可。 -//TODO **评审这段代码**@handongxu + ```js +let uobc = require('uni-open-bridge-common') +// 应用级凭据 const key = { dcloudAppid: '__UNI__xxx', // DCloud Appid platform: 'mp-weixin' // 平台,解释见下 -} -let uobc = require('uni-open-bridge-common') - +} uobc.getAccessToken(key) -uobc.getUserAccessToken(key) -uobc.getSessionKey(key) -uobc.getEncryptKey(key) uobc.getTicket(key) + +// 用户级凭据 +const userKey = { + dcloudAppid: '__UNI__xxx', // DCloud Appid + platform: 'mp-weixin', // 平台,解释见下 + openid: '' +} +uobc.getUserAccessToken(userKey) +uobc.getSessionKey(userKey) +uobc.getEncryptKey(userKey) + ``` #### Platform@platform -- GitLab