微信登录

微信开发文档:https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html

测试账号:http://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo&t=sandbox/index

wxd0ebb83a1388ffbb

d6f58b5c312a9c2d9f4bd3b62fcb9ef2


https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd0ebb83a1388ffbb&redirect_uri=http://127.0.0.1:80&response_type=code&scope=snsapi_userinfo&state=1111#wechat_redirect  

https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd0ebb83a1388ffbb&redirect_uri=http://yuanxiaoxiang.com&response_type=code&scope=snsapi_userinfo&state=1111#wechat_redirect  

https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd0ebb83a1388ffbb&redirect_uri=http://yosebee.iask.in&response_type=code&scope=snsapi_userinfo&state=1111#wechat_redirect    

这两个路径都ok只需要修改下图即可




需要安装:https://developers.weixin.qq.com/miniprogram/dev/devtools/nightly.html(微信web开发者工具)






第二步:通过code换取网页授权access_token  

https://api.weixin.qq.com/sns/oauth2/access_token?appid=wxd0ebb83a1388ffbb&secret=d6f58b5c312a9c2d9f4bd3b62fcb9ef2&code=021lT8EC02SWuh2yAsBC0fH2EC0lT8EV&grant_type=authorization_code  


拉取用户信息(需scope为 snsapi_userinfo) 


https://api.weixin.qq.com/sns/userinfo?access_token=32_HYYYOFvAR76qSNxQnANhdbfztAm-Y-i4vaMWS-QxUOv9dxgzFLrM-XguK40GRz1H7ho-wAdurAMAc2FCV9IWDw&openid=o3IzZvqnATrpQBmxL9kueTZz6Z_4&lang=zh_CN  



https://open.weixin.qq.com/connect/qrconnect?appid=wxd0ebb83a1388ffbb&redirect_uri=http://yuanxiaoxiang.com&response_type=code&scope=snsapi_login&state=1111#wechat_redirect