路径:【管理后台】-【系统】-【用户设置】-【登陆】-【微信】
微信登陆有四个方式:微信网页登录、微信内分享登录、手机浏览器微信登录、手机APP微信登录。
微信网页登录与微信内分享登陆的区别是,分享登陆是指在微信内浏览器登陆要跳转地址的授权,开通接口后,用户可以在微信内直接打开跳转地址的连接,用微信账号登陆。而微信网页登陆,则是通过PC端登入跳转地址,微信扫描二维码授权,
PC端授权登陆:
申请地址:微信开放平台--网站应用开发
到授权页面 https://open.weixin.qq.com/connect/qrconnect?appid=AppID&redirect_uri=redirect_uri&response_type=code&scope=snsapi_login&state=STATE&connect_redirect=1
如果用户同意授权会跳转到redirect_uri/?code=CODE&state=STATE地址。
获取access_token
payload = {'appid':AppID,'secret':AppSecret,'code':code,'grant_type':'authorization_code'}
requests.get('https://api.weixin.qq.com/sns/oauth2/access_token',params = payload)
校验access_token
https://api.weixin.qq.com/sns/auth?access_token=ACCESS_TOKEN&openid=OPENID
刷新access_token
https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=APPID&grant_type=refresh_token&refresh_token=REFRESH_TOKEN
获取用户信息
https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID
微信浏览器授权登陆
微信服务号申请地址:微信公众平台
进入微信开放平台,顶部导航【管理中心】,绑定微信公众号,绑定后才能呢个去用数据,才能进行微信内浏览器授权登陆
进入授权页面
url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=AppID&redirect_uri=redirect_uri&response_type=code&scope=snsapi_userinfo&state=STATE&connect_redirect=1#wechat_redirect";
获取access_token
payload = {'appid':AppID,'secret':AppSecret,'code':code,'grant_type':'authorization_code'}
requests.get('https://api.weixin.qq.com/sns/oauth2/access_token',params = payload)
校验access_token
https://api.weixin.qq.com/sns/auth?access_token=ACCESS_TOKEN&openid=OPENID
刷新access_token
https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=APPID&grant_type=refresh_token&refresh_token=REFRESH_TOKEN
获取用户信息
https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID