Java微信登录
用到的開源類庫:https://github.com/justauth/JustAuth
開源類庫的Demo:https://github.com/justauth/JustAuth-demo
可參考文檔:
https://www.cnblogs.com/chenghao24/p/12234122.html
https://www.cnblogs.com/xxpeng/p/4832051.html
首先需要去微信開放平臺注冊申請:https://open.weixin.qq.com/
審核通過之后可以在應用詳情中看到
配置的時候配置接受回調域只可以是www.baidu.com 這種 ,不可以帶http 和 /
否則會報錯 redirect_uri 參數錯誤
遇到的坑:
1.scope域應設置為:snsapi_login
2.redirect_uri 參數錯誤
是因為申請的時候回調域 www.baidu.com 這種
而redirect_uri 參數 應該是 回調域下的 http 或者 https 開頭的
我們配置的回調地址與回調域不同,回調地址必須在回調域下面
如官方給的例子中地址是:https://open.weixin.qq.com/connect/qrconnect?appid=wxbdc5610cc59c1631&redirect_uri=https%3A%2F%2Fpassport.yhd.com%2Fwechat%2Fcallback.do&response_type=code&scope=snsapi_login&state=3d6be0a4035d839573b04816624a415e#wechat_redirect
3,.請在微信客戶端發開
總結
- 上一篇: 分享一个关于Java调用百度、高德API
- 下一篇: Java按规则生成唯一编号