Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dcloudio/uni-account

Package Overview
Dependencies
Maintainers
5
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dcloudio/uni-account

uniAccount from uniCloud

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
5
Weekly downloads
 
Created
Source

简介

uniAccount是一个适用于多端的用户身份管理工具。uniAccount内部对不同平台的 api 进行了拉齐,有助于开发者更方便的调用相关功能。

引入 uniAccount

开发者可以自行选择是从插件市场导入还是从 npm 安装,引入方式略有不同,请看下面示例

// 插件市场导入
const uniAccount = require('uni-account')

// npm安装
const uniAccount = require('@dcloudio/uni-account')

初始化

进行初始化操作返回 uniAccount 实例

微信小程序

入参说明

参数名类型默认值必填说明
appIdString-小程序 ID
secretString--小程序密钥
timeoutNumber5000请求超时时间,单位:毫秒
const uniAccountIns = uniAccount.initWeixin({
  appId,
  secret,
})

支付宝小程序

入参说明

参数名类型默认值必填说明
appIdString-小程序 ID
privateKeyString-小程序应用私钥
timeoutNumber5000请求超时时间,单位:毫秒
const uniAccountIns = uniAccount.initAlipay({
  appId,
  privateKey,
})

Api 列表

获取 openid

uniAccountIns.code2Session。传入uni.login返回的code来获取用户 openid 等信息

入参说明

参数名类型默认值必填说明
codeString-uni.login 获取的用户 code

返回值说明

属性类型说明支持平台
openidString用户唯一标识支付宝小程序、微信小程序
sessionKeyString会话密钥微信小程序
unionidString用户唯一标识符微信小程序

注意

  • UnionID 为用户在微信开放平台的唯一标识符,在满足 UnionID 下发条件的情况下会返回,详见 UnionID 机制说明

示例代码

const { openid } = await uniAccountIns.code2Session(code)

更多 Api 正在补充

FAQs

Package last updated on 16 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc