The login process

  1. Small program passwx.loginTo obtaincode(User login credentials, valid for five minutes, valid after using once)
  2. Server side getcode, the callcode2SessionTo get the user’sopenid(Unique id of the user in the current application),unionid(Unique identification of the user on the development platform)session_keySession key is used for user dataEncrypted signatureIs used to obtain user information. For security, the serverThe session secret key should not be issued to applets, nor should it be made available externally
  3. throughunionid openidCustomize the server login state

Obtaining User information

  1. After the user is authorized, the applets obtain user information through wx.getUserInfo, and sensitive information is encrypted
  2. Pass the encrypted information to the server, using the information obtained during loginsession_keyDecrypt data, decryption method can see wechatOpen data validation and decryption documents

Obtaining mobile phone Number

Need the user to initiate the active trigger to get the phone number interface, so this function is not API to call, need to use

  1. Small program pass<button>Component to triggergetPhoneNumberEvent to obtain encrypted information
  2. Pass the encrypted information to the server, using the information obtained during loginsession_keyDecrypt the data and obtain the mobile phone number bound to the user

The following is a front and back end interaction flow chart I draw in the actual development, welcome to point out the shortcomings.

Reference documentation

Applets development documentation