egg-weapp-oauth

1.0.6 • Public • Published

egg-weapp-oauth

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Install

$ npm i egg-weapp-oauth --save

Usage

// {app_root}/config/plugin.js
exports.weappOauth = {
  enable: true,
  package: 'egg-weapp-oauth',
};

Configuration

// {app_root}/config/config.default.js
exports.weappOauth = {
    appid: '',
    secret: ''
};

see config/config.default.js for more detail.

Example

API 列表

getUser: 通过code获取用户信息:

let user = await app.weappOauth.getUser(code, encryptoData<可选>, iv<可选>);
// user: {openid, unionid, session_key, expires_in}
// user.userInfo: {openId, nickName, gender, language, city, province, country, avatarUrl, unionId, watermark}

特殊说明

  • encryptoData和iv为可选参数, 存在时进行解密并附加一个名为userInfo的Object;
  • unionid返回规则: UnionID机制说明

decrypt: 解密用户信息

let user = await app.weappOauth.decrypt(encryptoData, session_key, iv);

Questions & Suggestions

Please open an issue here.

License

MIT

Package Sidebar

Install

npm i egg-weapp-oauth

Weekly Downloads

3

Version

1.0.6

License

MIT

Unpacked Size

8.53 kB

Total Files

7

Last publish

Collaborators

  • bulolo