微信登录之二级(误:任意)域名的授权登录

应用场景:

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属于公众平台。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值