应用场景:
test.com可通过微信登录。此时,另一个网站dev.test.com也想通过微信登录,但是dev.test.com微信没有登录权
1、在主站引入
https://github.com/HADB/GetWeixinCode项目资源将本文件放置在适当的位置
2、 配置授权URL
authorize_url=http://test.com/static/html/get-weixin-code.html
不直接通过微信授权,而是通过微信授权URL进行授权
3、配置回调地址
redirect_uri=/oauth/authc/weixin
自定义回调URL
4、需要授权时访问的URL
1)开放平台(扫码登录)
url = authorize_url "?" "appid=" appid "&redirect_uri="
URLEncoder.encode(request.getScheme() "://" request.getServerName() redirect_uri,"UTF-8") "&response_type=" response_type "&scope=" scope
"&state=" state;
2)公共平台(默默登录微信客户端)
url = authorize_url "?" "appid=" weixinAppid "&redirect_uri="
URLEncoder.encode(request.getScheme() "://" request.getServerName() redirect_uri.replace("weixin","weixin_mp"),"UTF-8") "&response_type=" response_type "&scope=snsapi_userinfo"
"&state=" state "#wechat_redirect";
备注:weixinAppid!=appid,appid属于开发平台,weixinAppid属于公共平台。
扫码咨询与免费使用
加我们 免费用
立即获取免费试用
立即咨询