Technology Sharing

Uniapp WeChat applet implements WeChat login

2024-07-08

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

I read some information online and it seems that you need to call uni.getUserProfile or uni.getUserInfo to get the user information first, and then call uni.login. However, when I look at uni.getUserProfile and uni.getUserInfo, they all return anonymous information (nickName: "WeChat user", and the avatar is also a uniform gray avatar). I don't know what they are used for. It should be that they were able to return normally before, but later in which version, probably for the sake of user privacy and security, they all returned anonymous information.

The above are some APIs provided by the uniapp official website, the addresses are as follows:

https://uniapp.dcloud.net.cn/api/plugins/login.html#login

These are some APIs for obtaining authorization information. In addition, uniapp also provides button component settings for open-type to make it easier for us to obtain authorization information, as follows: