wechat-mini-program-auth
(Non-official) Wechat mini program auth helper for Node.js.
Table of Contents
Installation
yarn add wechat-mini-program-auth
Usage
; { const wechatAuth = appId: '<WECHAT_APP_ID>' appSecret: '<WECHAT_APP_SECRET>' ); const userInfo = await wechatAuth;};
Reference
constructor(appId, appSecret)
appId appSecret
Create a WechatMiniProgramAuth
instance.
Arguments
appId
<String>: Wechat app id, requiredappSecret
<String>: Wechat app secret, required
getUserInfo(params)
wechatMiniProgramAuth
Arguments
- Params <Object>
code
<String>:code
from wechat mini programwx.login()
sessionKey
<String>: Session key from getSession(params)rawData
<String>:rawData
from wechat mini programwx.getUserInfo()
signature
<String>:signature
from wechat mini programwx.getUserInfo()
encryptedData
<String>:encryptedData
from wechat mini programwx.getUserInfo()
iv
<String>:iv
from wechat mini programwx.getUserInfo()
Note
- One of
code
orsessionKey
is required - One of
rawData
andsignature
, orencryptedData
andiv
are required
Returns
Promise of UserInfo object
getSession(params)
wechatMiniProgramAuth
Arguments
- Params <Object>
code
<String>:code
from wechat mini programwx.login()
, required
Returns
Promise of object containing sessionKey
, openid
, and optional unionid
License
MIT