(Non-official) Wechat mini program (微信小程序) auth helper for Node.js
(Non-official) Wechat mini program (a.k.a. 微信小程序) auth helper for Node.js.
yarn add wxapp-auth
import WxappAuth from 'wxapp-auth';
(async function main() {
const wechatAuth = new WxappAuth('<APP_ID>', '<APP_SECRET>');
const userInfo = await wechatAuth.getUserInfo({
code: '<LOGIN_CODE>'
rawData: '<RAW_DATA>',
signature: '<SIGNATURE>',
});
}());
new WxappAuth(appId, appSecret);
Create a WxappAuth
instance.
appId
\appSecret
\
wxappAuth.getUserInfo(params);
code
\code
from wechat mini program wx.login()
sessionKey
\rawData
\rawData
from wechat mini program wx.getUserInfo()
signature
\signature
from wechat mini program wx.getUserInfo()
encryptedData
\encryptedData
from wechat mini program wx.getUserInfo()
iv
\iv
from wechat mini program wx.getUserInfo()
code
or sessionKey
is requiredrawData
and signature
, or encryptedData
and iv
are requiredPromise of UserInfo object
wxappAuth.getSession(params);
code
\code
from wechat mini program wx.login()
, requiredPromise of object containing sessionKey
, openid
, and optional unionid
MIT