2019/12/20

wechat miniapp login


  • wechat miniApp:  wx.login -> code
  • wechat miniApp: wx.request , send code to server api
  • server request 
    • wechat API,get openId and sesion_key: https://api.weixin.qq.com/sns/jscode2session?appid=a&secret=b&js_code=codegrant_type=authorization_code
    • use openId and session_key to generate access token
    • response access token and openId to miniAPP(token1)
  • wechat miniApp: wx.getSetting check user's authority.if not ,request user's authority.
  • wechat miniApp: wx.getUserInfo can get user info.
  • server request wechat api to get token(token2) :
    • https://api.weixin.qq.com/cgi-bin/token?appid=a&secret=b&grant_type=client_credential
  • server request wetchat api use token