I want to implement the login with WeChat. While reading the documentation, I came across two different parameters whose meaning I don't fully understand: openId and unionId.
Could someone explain what these id's really are? As far as I understood it should be like this:
openId - some unique id of the user that could change from time to time
unionId - the unique id of the user, the only one that is always the same. Equivalent to the unique id the Google returns when logging in using Google API.
The documentation I read can be found here: http://open.wechat.com/cgi-bin/newreadtemplate?t=overseas_open/docs/web/login/getting-user-profile#login_getting-user-profile
From my understanding, a user's open ids vary from web apps to apps, whereas union id stays the same. For example, you have two apps that use wechat login: W1 and W2. A user will have openid1 for W1 and oepnid2 for W2 seperately, but you can use the user's union id the uniquely identify him/her across the apps.
Open id only changes when you have more than one web/mobile apps.
Hope it helps. Thanks.
"why would anyone want to use an openID" - that is a very good question from @dcsan.
从api来讲的话,最大区别就是 unionId 需要 openId 和 access_token 去取得,也就是多了一个auth step。
从实用角度来看,openId更多起了一种 data anonymization 的作用。
除此之外 from what I understand,
openId = f(unionId, appId) where f是一个hash function,etc。
Update, it's probably something more like=
openid = f(userId, appId)
unionid = f(userId, appOwnerId)
where f是一个hash function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With