WeChat Mini Programs wx.login and wx.getUserinfo applicable scenarios

I have just learned about WeChat Mini Programs, but I don"t understand the applicable scenarios of wx.login and wx.getUserinfo. It seems that a code, will be returned in wx.login and then the user"s openid can be obtained by requesting the interface provided by Wechat through this code. In getUserinfo, you can decrypt the user"s openid directly through the returned encryptedData.
are there any associated points between these two interfaces? And. The call will pop up a box for the user to authorize.

Mar.15,2021

wx.login logs in and returns code to the server. After the server calls, Wechat will return openid, and a sessionkey, to the server (code can only be used once)

permission https://mp.weixin.qq.com/debu.
wx.getUserinfo needs the user's permission, that is, a pop-up box allows the user to authorize the information, regardless of whether the user is logged in or not, but some sensitive information can be obtained after logging in, and another is sign,. This is obtained by sha1 (userInfo + sessionkey). You can send userInfo and sign to the server, and the server then uses the above algorithm to verify whether the user information sent by the client is correct. You can't believe everything the customer says, can you?

In the information returned by

wx.getUserinfo, decrypting encryptedData needs to be obtained from wx.login in session_key,session_key. Therefore, if you want to get sensitive data, you must call the login interface.

Menu