JustAuth,如你所見,它僅僅是一個第三方授權登錄的工具類庫,它可以讓我們脫離繁瑣的第三方登錄SDK,讓登錄變得So easy!
特點
廢話不多說,就倆字:
- 全:已集成十多家第三方平臺(國內外常用的基本都已包含),仍然還在持續擴展中(開發計劃)!
- 簡:API就是奔著最簡單去設計的(見後面快速開始),儘量讓您用起來沒有障礙感!
快速開始
- 引入依賴
<dependency>
<groupid>me.zhyd.oauth/<groupid>
<artifactid>JustAuth/<artifactid>
<version>1.12.0/<version>
/<dependency>
- 調用api
// 創建授權request
AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder()
.clientId("clientId")
.clientSecret("clientSecret")
.redirectUri("redirectUri")
.build());
// 生成授權頁面
authRequest.authorize("state");
// 授權登錄後會返回code(auth_code(僅限支付寶))、state,1.8.0版本後,可以用AuthCallback類作為回調接口的參數
// 注:JustAuth默認保存state的時效為3分鐘,3分鐘內未使用則會自動清除過期的state
authRequest.login(callback);
配套Demo:
- Springboot版
- jFinal版: Jfinal集成JustAuth的demo by xkcoding
- ActFramework版: ActFramework 集成 JustAuth 的 demo by xkcoding
- Nutzboot版: NutzBoot集成JustAuth的demo by 蛋蛋
- Blade版: Blade集成JustAuth的demo
插件
- justauth-spring-boot-starter: Spring Boot 集成 JustAuth 的最佳實踐 by xkcoding
- justauth-spring-boot-starter-demo: Spring Boot 使用 justauth-spring-boot-starter 快速集成 JustAuth by xkcoding
具體的例子可以參考:
- 實現Gitee授權登錄
- 實現Github授權登錄
- Spring Boot 快速集成第三方登錄功能 : QQ、Github、微信、谷歌、微軟、小米、企業微信
- 集成企業微信
閱讀更多 程序魚 的文章