log如下
正常的:
[psyApi.Controllers.UserController]-Program.cs/Log/#187-33/2020-07-28 11:55:31,552 [63] - UserController.cs/Login/#21-701/WxRequest:{"session_key":"dVOaYYozuRo306AegNqauQ==","openid":"owZhI49YhalWrWxBYVFPEicbkORA","unionid":"oQcjnv5Ln6bxi1kNa22fZj7KKGTM"}
异常的:
[psyApi.Controllers.UserController]-Program.cs/Log/#187-34/2020-07-28 11:57:38,215 [68] - UserController.cs/Login/#21-742/WxRequest:{"session_key":"FC2dwRFEptnjMUi87Off3Q==","openid":"owZhI49rF9JBxG14KrIY3h98lOD4"}
咱们说明里面:
“如果开发者帐号下存在同主体的公众号,并且该用户已经关注了该公众号。开发者可以直接通过 wx.login + code2Session
获取到该用户 UnionID,无须用户再次授权。”
意思是不是,用户不关注公众号,我就拿不到UnionID
问题解决了!
参看
https://www.jianshu.com/p/46efa68d9033
结贴是个好习惯