1.0.6 • Published 6 years ago
egg-weapp-oauth v1.0.6
egg-weapp-oauth
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.