diff --git a/pom.xml b/pom.xml
index f411c408f7cc2d80b58e5ac7b6083739dc41eae1..4cacc20e1e5f5a2bed16aa2ae25bade7f59cc8f6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
me.zhyd.oauth
JustAuth
- 1.6.1-beta
+ 1.7.0
JustAuth
https://gitee.com/yadong.zhang/JustAuth
diff --git a/src/main/java/me/zhyd/oauth/authorization/AlipayAuthorization.java b/src/main/java/me/zhyd/oauth/authorization/AlipayAuthorization.java
deleted file mode 100644
index c5655fe35034aebf998913a1ceeb1bd80dbd5c5b..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/AlipayAuthorization.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.utils.UrlBuilder;
-
-/**
- * 支付宝授权
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @since 1.8
- */
-public class AlipayAuthorization implements Authorization {
-
- @Override
- public String getAuthorizeUrl(AuthConfig config) {
- return UrlBuilder.getAlipayAuthorizeUrl(config.getClientId(), config.getRedirectUri());
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/Authorization.java b/src/main/java/me/zhyd/oauth/authorization/Authorization.java
deleted file mode 100644
index f8508c42670c6576ce62d9f59428a66139671af8..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/Authorization.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-
-/**
- * 授权接口,用来获取具体第三方平台的授权地址
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @since 1.8
- */
-public interface Authorization {
-
- /**
- * 获取授权页面地址
- *
- * @param config 授权基础配置
- * @return 授权页面地址
- */
- String getAuthorizeUrl(AuthConfig config);
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/AuthorizationFactory.java b/src/main/java/me/zhyd/oauth/authorization/AuthorizationFactory.java
deleted file mode 100644
index 9a5cc3eb8a50b3f8e0b6478a08e5dcb1fd6ca54b..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/AuthorizationFactory.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.AuthSource;
-import me.zhyd.oauth.request.ResponseStatus;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * 授权工厂类,负责创建指定平台的授权类获取授权地址
- *
- * 使用策略模式 + 工厂模式 避免大量的if else(switch)操作
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @since 1.8
- */
-public class AuthorizationFactory {
-
- private static Map authorizationMap = new HashMap<>();
- private static boolean loader = false;
-
- private AuthorizationFactory() {
-
- }
-
- /**
- * 根据第三方平台,获取具体的授权工具
- *
- * @param source 平台
- * @return 具体的Authorization
- */
- public static Authorization getAuthorize(AuthSource source) {
- if (null == source) {
- throw new AuthException(ResponseStatus.NO_AUTH_SOURCE);
- }
- registerAllAuthorize();
-
- Authorization authorization = authorizationMap.get(source.toString());
- if (null == authorization) {
- throw new AuthException(ResponseStatus.UNIDENTIFIED_PLATFORM);
- }
- return authorization;
- }
-
- /**
- * 将所有Authorize的实现类注册到authorizeMap中,
- * 每次增加新的平台都需要在这儿添加注册代码
- */
- private static void registerAllAuthorize() {
- if (loader) {
- return;
- }
- AuthorizationFactory.register(AuthSource.ALIPAY, new AlipayAuthorization());
- AuthorizationFactory.register(AuthSource.BAIDU, new BaiduAuthorization());
- AuthorizationFactory.register(AuthSource.CODING, new CodingAuthorization());
- AuthorizationFactory.register(AuthSource.CSDN, new CsdnAuthorization());
- AuthorizationFactory.register(AuthSource.DINGTALK, new DingTalkAuthorization());
- AuthorizationFactory.register(AuthSource.GITEE, new GiteeAuthorization());
- AuthorizationFactory.register(AuthSource.GITHUB, new GithubAuthorization());
- AuthorizationFactory.register(AuthSource.GOOGLE, new GoogleAuthorization());
- AuthorizationFactory.register(AuthSource.OSCHINA, new OschinaAuthorization());
- AuthorizationFactory.register(AuthSource.QQ, new QqAuthorization());
- AuthorizationFactory.register(AuthSource.TAOBAO, new TaobaoAuthorization());
- AuthorizationFactory.register(AuthSource.TENCENT_CLOUD, new TencentCloudAuthorization());
- AuthorizationFactory.register(AuthSource.WECHAT, new WeChatAuthorization());
- AuthorizationFactory.register(AuthSource.WEIBO, new WeiboAuthorization());
- AuthorizationFactory.register(AuthSource.FACEBOOK, new FacebookAuthorization());
- AuthorizationFactory.register(AuthSource.DOUYIN, new DouyinAuthorization());
- AuthorizationFactory.register(AuthSource.LINKEDIN, new LinkedinAuthorization());
- AuthorizationFactory.register(AuthSource.MICROSOFT, new MicrosoftAuthorization());
- AuthorizationFactory.register(AuthSource.MI, new MiAuthorization());
- AuthorizationFactory.register(AuthSource.TOUTIAO, new ToutiaoAuthorization());
- loader = true;
- }
-
- private static void register(AuthSource authSource, Authorization authorization) {
- authorizationMap.put(authSource.toString(), authorization);
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/BaiduAuthorization.java b/src/main/java/me/zhyd/oauth/authorization/BaiduAuthorization.java
deleted file mode 100644
index c7e346965b80cca3b7b5f9cbbe511176fdc79712..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/BaiduAuthorization.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.utils.UrlBuilder;
-
-/**
- * 百度授权
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @since 1.8
- */
-public class BaiduAuthorization implements Authorization {
-
- @Override
- public String getAuthorizeUrl(AuthConfig config) {
- return UrlBuilder.getBaiduAuthorizeUrl(config.getClientId(), config.getRedirectUri());
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/CodingAuthorization.java b/src/main/java/me/zhyd/oauth/authorization/CodingAuthorization.java
deleted file mode 100644
index dd0128649410e9a5e1e735cc0e00b4871dbfc362..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/CodingAuthorization.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.utils.UrlBuilder;
-
-/**
- * Coding授权
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @since 1.8
- */
-public class CodingAuthorization implements Authorization {
-
- @Override
- public String getAuthorizeUrl(AuthConfig config) {
- return UrlBuilder.getCodingAuthorizeUrl(config.getClientId(), config.getRedirectUri());
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/CsdnAuthorization.java b/src/main/java/me/zhyd/oauth/authorization/CsdnAuthorization.java
deleted file mode 100644
index cc6474cfec990e0aba07d986459b9a22ce98fdd5..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/CsdnAuthorization.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.utils.UrlBuilder;
-
-/**
- * CSDN授权
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @since 1.8
- */
-public class CsdnAuthorization implements Authorization {
-
- @Override
- public String getAuthorizeUrl(AuthConfig config) {
- return UrlBuilder.getCsdnAuthorizeUrl(config.getClientId(), config.getRedirectUri());
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/DingTalkAuthorization.java b/src/main/java/me/zhyd/oauth/authorization/DingTalkAuthorization.java
deleted file mode 100644
index 4bda11e456ba4301222553256b79aed05a66065b..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/DingTalkAuthorization.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.utils.UrlBuilder;
-
-/**
- * 钉钉授权
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @since 1.8
- */
-public class DingTalkAuthorization implements Authorization {
-
- @Override
- public String getAuthorizeUrl(AuthConfig config) {
- return UrlBuilder.getDingTalkQrConnectUrl(config.getClientId(), config.getRedirectUri());
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/DouyinAuthorization.java b/src/main/java/me/zhyd/oauth/authorization/DouyinAuthorization.java
deleted file mode 100644
index a374399f13ee1ea591878d7f309847d2e445c076..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/DouyinAuthorization.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.utils.UrlBuilder;
-
-/**
- * 抖音授权
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @since 1.8
- */
-public class DouyinAuthorization implements Authorization {
-
- @Override
- public String getAuthorizeUrl(AuthConfig config) {
- return UrlBuilder.getDouyinAuthorizeUrl(config.getClientId(), config.getRedirectUri());
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/FacebookAuthorization.java b/src/main/java/me/zhyd/oauth/authorization/FacebookAuthorization.java
deleted file mode 100644
index 7862aa5863023972584a91876eb333a5e35b213e..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/FacebookAuthorization.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.utils.UrlBuilder;
-
-/**
- * Facebook授权
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.3
- * @since 1.3
- */
-public class FacebookAuthorization implements Authorization {
-
- @Override
- public String getAuthorizeUrl(AuthConfig config) {
- return UrlBuilder.getFacebookAuthorizeUrl(config.getClientId(), config.getRedirectUri());
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/GiteeAuthorization.java b/src/main/java/me/zhyd/oauth/authorization/GiteeAuthorization.java
deleted file mode 100644
index e02a476a8103050da891b87d6acc2e7e34972325..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/GiteeAuthorization.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.utils.UrlBuilder;
-
-/**
- * 码云授权
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @since 1.8
- */
-public class GiteeAuthorization implements Authorization {
-
- @Override
- public String getAuthorizeUrl(AuthConfig config) {
- return UrlBuilder.getGiteeAuthorizeUrl(config.getClientId(), config.getRedirectUri());
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/GithubAuthorization.java b/src/main/java/me/zhyd/oauth/authorization/GithubAuthorization.java
deleted file mode 100644
index f77ceb419c64886073ec861e4dd7d4a48746a6bb..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/GithubAuthorization.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.utils.UrlBuilder;
-
-/**
- * Github授权
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @since 1.8
- */
-public class GithubAuthorization implements Authorization {
-
- @Override
- public String getAuthorizeUrl(AuthConfig config) {
- return UrlBuilder.getGithubAuthorizeUrl(config.getClientId(), config.getRedirectUri());
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/GoogleAuthorization.java b/src/main/java/me/zhyd/oauth/authorization/GoogleAuthorization.java
deleted file mode 100644
index 6a6b318f1b5095e4796721bf3d73bb2fe48d7524..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/GoogleAuthorization.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.utils.UrlBuilder;
-
-/**
- * Google授权
- *
- * @author yangkai.shen (https://xkcoding.com)
- * @version 1.3
- * @since 1.3
- */
-public class GoogleAuthorization implements Authorization {
-
- @Override
- public String getAuthorizeUrl(AuthConfig config) {
- return UrlBuilder.getGoogleAuthorizeUrl(config.getClientId(), config.getRedirectUri());
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/LinkedinAuthorization.java b/src/main/java/me/zhyd/oauth/authorization/LinkedinAuthorization.java
deleted file mode 100644
index 0cb60be90b59b02e352ae83093213435089f7f29..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/LinkedinAuthorization.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.utils.UrlBuilder;
-
-/**
- * 领英授权
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @since 1.8
- */
-public class LinkedinAuthorization implements Authorization {
-
- @Override
- public String getAuthorizeUrl(AuthConfig config) {
- return UrlBuilder.getLinkedinAuthorizeUrl(config.getClientId(), config.getRedirectUri());
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/MiAuthorization.java b/src/main/java/me/zhyd/oauth/authorization/MiAuthorization.java
deleted file mode 100644
index 2fb0ff678e23f145e7d1da003cdd9b238394916c..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/MiAuthorization.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.utils.UrlBuilder;
-
-/**
- * 小米授权
- *
- * @author yangkai.shen (https://xkcoding.com)
- * @version 1.5
- * @since 1.5
- */
-public class MiAuthorization implements Authorization {
-
- @Override
- public String getAuthorizeUrl(AuthConfig config) {
- return UrlBuilder.getMiAuthorizeUrl(config.getClientId(), config.getRedirectUri());
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/MicrosoftAuthorization.java b/src/main/java/me/zhyd/oauth/authorization/MicrosoftAuthorization.java
deleted file mode 100644
index 4dff7244fc6f9f9783926175f04be5cfcd221814..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/MicrosoftAuthorization.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.utils.UrlBuilder;
-
-/**
- * 微软授权
- *
- * @author yangkai.shen (https://xkcoding.com)
- * @version 1.5
- * @since 1.5
- */
-public class MicrosoftAuthorization implements Authorization {
-
- @Override
- public String getAuthorizeUrl(AuthConfig config) {
- return UrlBuilder.getMicrosoftAuthorizeUrl(config.getClientId(), config.getRedirectUri());
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/OschinaAuthorization.java b/src/main/java/me/zhyd/oauth/authorization/OschinaAuthorization.java
deleted file mode 100644
index fa70aaf696b78e25d986864532edc4d7f1c65373..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/OschinaAuthorization.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.utils.UrlBuilder;
-
-/**
- * 开源中国授权
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @since 1.8
- */
-public class OschinaAuthorization implements Authorization {
-
- @Override
- public String getAuthorizeUrl(AuthConfig config) {
- return UrlBuilder.getOschinaAuthorizeUrl(config.getClientId(), config.getRedirectUri());
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/QqAuthorization.java b/src/main/java/me/zhyd/oauth/authorization/QqAuthorization.java
deleted file mode 100644
index f9002365b9cf79985b69eb58f6050670409d1b0e..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/QqAuthorization.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.utils.UrlBuilder;
-
-/**
- * QQ授权
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @since 1.8
- */
-public class QqAuthorization implements Authorization {
-
- @Override
- public String getAuthorizeUrl(AuthConfig config) {
- return UrlBuilder.getQqAuthorizeUrl(config.getClientId(), config.getRedirectUri());
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/TaobaoAuthorization.java b/src/main/java/me/zhyd/oauth/authorization/TaobaoAuthorization.java
deleted file mode 100644
index cdc8370b48b61eca6573b6621439ec970f805254..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/TaobaoAuthorization.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.utils.UrlBuilder;
-
-/**
- * 淘宝授权
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @since 1.8
- */
-public class TaobaoAuthorization implements Authorization {
-
- @Override
- public String getAuthorizeUrl(AuthConfig config) {
- return UrlBuilder.getTaobaoAuthorizeUrl(config.getClientId(), config.getRedirectUri());
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/TencentCloudAuthorization.java b/src/main/java/me/zhyd/oauth/authorization/TencentCloudAuthorization.java
deleted file mode 100644
index dcb94fe5210a82e4fbd0d7a9c3530f3d129028a9..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/TencentCloudAuthorization.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.utils.UrlBuilder;
-
-/**
- * 腾讯云授权
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @since 1.8
- */
-public class TencentCloudAuthorization implements Authorization {
-
- @Override
- public String getAuthorizeUrl(AuthConfig config) {
- return UrlBuilder.getTencentCloudAuthorizeUrl(config.getClientId(), config.getRedirectUri());
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/ToutiaoAuthorization.java b/src/main/java/me/zhyd/oauth/authorization/ToutiaoAuthorization.java
deleted file mode 100644
index eb110d36061e1011c93afdcdfe43cc515393d5fe..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/ToutiaoAuthorization.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.utils.UrlBuilder;
-
-/**
- * 今日头条授权
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @since 1.8
- */
-public class ToutiaoAuthorization implements Authorization {
-
- @Override
- public String getAuthorizeUrl(AuthConfig config) {
- return UrlBuilder.getToutiaoAuthorizeUrl(config.getClientId(), config.getRedirectUri());
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/WeChatAuthorization.java b/src/main/java/me/zhyd/oauth/authorization/WeChatAuthorization.java
deleted file mode 100644
index a7f208a25e6c8a35b3299c334288f1a2c593c419..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/WeChatAuthorization.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.utils.UrlBuilder;
-
-/**
- * 微信授权
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @since 1.8
- */
-public class WeChatAuthorization implements Authorization {
-
- @Override
- public String getAuthorizeUrl(AuthConfig config) {
- return UrlBuilder.getWeChatAuthorizeUrl(config.getClientId(), config.getRedirectUri());
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/authorization/WeiboAuthorization.java b/src/main/java/me/zhyd/oauth/authorization/WeiboAuthorization.java
deleted file mode 100644
index 2083233af1301d845d61fc4cc3c46d8921a40bc1..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/authorization/WeiboAuthorization.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package me.zhyd.oauth.authorization;
-
-import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.utils.UrlBuilder;
-
-/**
- * 微博授权
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @since 1.8
- */
-public class WeiboAuthorization implements Authorization {
-
- @Override
- public String getAuthorizeUrl(AuthConfig config) {
- return UrlBuilder.getWeiboAuthorizeUrl(config.getClientId(), config.getRedirectUri());
- }
-}
diff --git a/src/main/java/me/zhyd/oauth/consts/ApiUrl.java b/src/main/java/me/zhyd/oauth/config/AuthSource.java
similarity index 69%
rename from src/main/java/me/zhyd/oauth/consts/ApiUrl.java
rename to src/main/java/me/zhyd/oauth/config/AuthSource.java
index 894bc83d21216bc60dd07290cd26d5535c0df54d..14d51ea431bff643f5d53c59cffc75ae0d800d5c 100644
--- a/src/main/java/me/zhyd/oauth/consts/ApiUrl.java
+++ b/src/main/java/me/zhyd/oauth/config/AuthSource.java
@@ -1,4 +1,4 @@
-package me.zhyd.oauth.consts;
+package me.zhyd.oauth.config;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.request.ResponseStatus;
@@ -10,7 +10,7 @@ import me.zhyd.oauth.request.ResponseStatus;
* @version 1.0
* @since 1.0
*/
-public enum ApiUrl {
+public enum AuthSource {
/**
* Github
*/
@@ -29,16 +29,6 @@ public enum ApiUrl {
public String userInfo() {
return "https://api.github.com/user";
}
-
- @Override
- public String revoke() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
-
- @Override
- public String refresh() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
},
/**
* 新浪微博
@@ -58,16 +48,6 @@ public enum ApiUrl {
public String userInfo() {
return "https://api.weibo.com/2/users/show.json";
}
-
- @Override
- public String revoke() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
-
- @Override
- public String refresh() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
},
/**
* gitee
@@ -87,16 +67,6 @@ public enum ApiUrl {
public String userInfo() {
return "https://gitee.com/api/v5/user";
}
-
- @Override
- public String revoke() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
-
- @Override
- public String refresh() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
},
/**
* 钉钉
@@ -116,16 +86,6 @@ public enum ApiUrl {
public String userInfo() {
return "https://oapi.dingtalk.com/sns/getuserinfo_bycode";
}
-
- @Override
- public String revoke() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
-
- @Override
- public String refresh() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
},
/**
* 百度
@@ -150,11 +110,6 @@ public enum ApiUrl {
public String revoke() {
return "https://openapi.baidu.com/rest/2.0/passport/auth/revokeAuthorization";
}
-
- @Override
- public String refresh() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
},
/**
* csdn
@@ -174,16 +129,6 @@ public enum ApiUrl {
public String userInfo() {
return "https://api.csdn.net/user/getinfo";
}
-
- @Override
- public String revoke() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
-
- @Override
- public String refresh() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
},
/**
* Coding
@@ -203,21 +148,11 @@ public enum ApiUrl {
public String userInfo() {
return "https://coding.net/api/account/current_user";
}
-
- @Override
- public String revoke() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
-
- @Override
- public String refresh() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
},
/**
* 腾讯云开发者平台(coding升级后就变成腾讯云开发者平台了)
*/
- TENCENTCLOUD {
+ TENCENT_CLOUD {
@Override
public String authorize() {
return "https://dev.tencent.com/oauth_authorize.html";
@@ -232,16 +167,6 @@ public enum ApiUrl {
public String userInfo() {
return "https://dev.tencent.com/api/account/current_user";
}
-
- @Override
- public String revoke() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
-
- @Override
- public String refresh() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
},
/**
* oschina 开源中国
@@ -261,16 +186,6 @@ public enum ApiUrl {
public String userInfo() {
return "https://www.oschina.net/action/openapi/user";
}
-
- @Override
- public String revoke() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
-
- @Override
- public String refresh() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
},
/**
* 支付宝
@@ -290,16 +205,6 @@ public enum ApiUrl {
public String userInfo() {
return "https://openapi.alipay.com/gateway.do";
}
-
- @Override
- public String revoke() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
-
- @Override
- public String refresh() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
},
/**
* QQ
@@ -319,16 +224,6 @@ public enum ApiUrl {
public String userInfo() {
return "https://graph.qq.com/user/get_user_info";
}
-
- @Override
- public String revoke() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
-
- @Override
- public String refresh() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
},
/**
* 微信
@@ -349,11 +244,6 @@ public enum ApiUrl {
return "https://api.weixin.qq.com/sns/userinfo";
}
- @Override
- public String revoke() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
-
@Override
public String refresh() {
return "https://api.weixin.qq.com/sns/oauth2/refresh_token";
@@ -377,16 +267,6 @@ public enum ApiUrl {
public String userInfo() {
throw new AuthException(ResponseStatus.UNSUPPORTED);
}
-
- @Override
- public String revoke() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
-
- @Override
- public String refresh() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
},
/**
* Google
@@ -406,16 +286,6 @@ public enum ApiUrl {
public String userInfo() {
return "https://oauth2.googleapis.com/tokeninfo";
}
-
- @Override
- public String revoke() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
-
- @Override
- public String refresh() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
},
/**
* Facebook
@@ -435,16 +305,6 @@ public enum ApiUrl {
public String userInfo() {
return "https://graph.facebook.com/v3.3/me";
}
-
- @Override
- public String revoke() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
-
- @Override
- public String refresh() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
},
/**
* 抖音
@@ -465,11 +325,6 @@ public enum ApiUrl {
return "https://open.douyin.com/oauth/userinfo";
}
- @Override
- public String revoke() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
-
@Override
public String refresh() {
return "https://open.douyin.com/oauth/refresh_token";
@@ -494,11 +349,6 @@ public enum ApiUrl {
return "https://api.linkedin.com/v2/me";
}
- @Override
- public String revoke() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
-
@Override
public String refresh() {
return "https://www.linkedin.com/oauth/v2/accessToken";
@@ -523,11 +373,6 @@ public enum ApiUrl {
return "https://graph.microsoft.com/v1.0/me";
}
- @Override
- public String revoke() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
-
@Override
public String refresh() {
return "https://login.microsoftonline.com/common/oauth2/v2.0/token";
@@ -552,11 +397,6 @@ public enum ApiUrl {
return "https://open.account.xiaomi.com/user/profile";
}
- @Override
- public String revoke() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
-
@Override
public String refresh() {
return "https://account.xiaomi.com/oauth2/token";
@@ -580,16 +420,6 @@ public enum ApiUrl {
public String userInfo() {
return "https://open.snssdk.com/data/user_profile";
}
-
- @Override
- public String revoke() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
-
- @Override
- public String refresh() {
- throw new AuthException(ResponseStatus.UNSUPPORTED);
- }
};
/**
@@ -618,13 +448,17 @@ public enum ApiUrl {
*
* @return url
*/
- public abstract String revoke();
+ public String revoke() {
+ throw new AuthException(ResponseStatus.UNSUPPORTED);
+ }
/**
* 刷新授权的api
*
* @return url
*/
- public abstract String refresh();
+ public String refresh() {
+ throw new AuthException(ResponseStatus.UNSUPPORTED);
+ }
-}
+}
\ No newline at end of file
diff --git a/src/main/java/me/zhyd/oauth/model/AuthSource.java b/src/main/java/me/zhyd/oauth/model/AuthSource.java
deleted file mode 100644
index fa0c375ad5c35425bda79a33963e84cc05100bf4..0000000000000000000000000000000000000000
--- a/src/main/java/me/zhyd/oauth/model/AuthSource.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package me.zhyd.oauth.model;
-
-/**
- * 授权来源(平台)
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @since 1.8
- */
-public enum AuthSource {
- GITHUB,
- GITEE,
- WEIBO,
- DINGTALK,
- BAIDU,
- CSDN,
- CODING,
- OSCHINA,
- TENCENT_CLOUD,
- ALIPAY,
- TAOBAO,
- QQ,
- WECHAT,
- GOOGLE,
- FACEBOOK,
- DOUYIN,
- LINKEDIN,
- MICROSOFT,
- MI,
- TOUTIAO
-}
diff --git a/src/main/java/me/zhyd/oauth/model/AuthUser.java b/src/main/java/me/zhyd/oauth/model/AuthUser.java
index 1079574e5d10464e78a70987af043737489cd350..35a5d02d99de0b6cfb4b1be878bf52d0c5818e3b 100644
--- a/src/main/java/me/zhyd/oauth/model/AuthUser.java
+++ b/src/main/java/me/zhyd/oauth/model/AuthUser.java
@@ -2,6 +2,7 @@ package me.zhyd.oauth.model;
import lombok.Builder;
import lombok.Data;
+import me.zhyd.oauth.config.AuthSource;
/**
* 授权成功后的用户信息,根据授权平台的不同,获取的数据完整性也不同
diff --git a/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java b/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java
index 521cdd43ecb8a71902137301fef7722a4ac58aca..db414ae95805b44ccf76917cd9f2f741fb8e5af5 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java
@@ -8,13 +8,13 @@ import com.alipay.api.request.AlipayUserInfoShareRequest;
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
import com.alipay.api.response.AlipayUserInfoShareResponse;
import me.zhyd.oauth.config.AuthConfig;
-import me.zhyd.oauth.consts.ApiUrl;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.AuthSource;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.utils.StringUtils;
+import me.zhyd.oauth.utils.UrlBuilder;
/**
* 支付宝登录
@@ -29,7 +29,8 @@ public class AuthAlipayRequest extends BaseAuthRequest {
public AuthAlipayRequest(AuthConfig config) {
super(config, AuthSource.ALIPAY);
- this.alipayClient = new DefaultAlipayClient(ApiUrl.ALIPAY.accessToken(), config.getClientId(), config.getClientSecret(), "json", "UTF-8", config.getAlipayPublicKey(), "RSA2");
+ this.alipayClient = new DefaultAlipayClient(AuthSource.ALIPAY.accessToken(), config.getClientId(), config.getClientSecret(), "json", "UTF-8", config
+ .getAlipayPublicKey(), "RSA2");
}
@Override
@@ -83,4 +84,14 @@ public class AuthAlipayRequest extends BaseAuthRequest {
.source(AuthSource.ALIPAY)
.build();
}
+
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
+ @Override
+ public String authorize() {
+ return UrlBuilder.getAlipayAuthorizeUrl(config.getClientId(), config.getRedirectUri());
+ }
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java b/src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java
index 73756252eba7cccf734ede413a3258f562cdf4ed..2225cacf11d585f08f63b430df196d677494a252 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java
@@ -3,8 +3,8 @@ package me.zhyd.oauth.request;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
-import lombok.extern.slf4j.Slf4j;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.*;
import me.zhyd.oauth.utils.UrlBuilder;
@@ -24,16 +24,15 @@ public class AuthBaiduRequest extends BaseAuthRequest {
@Override
protected AuthToken getAccessToken(String code) {
- String accessTokenUrl = UrlBuilder.getBaiduAccessTokenUrl(config.getClientId(), config.getClientSecret(), code, config.getRedirectUri());
+ String accessTokenUrl = UrlBuilder.getBaiduAccessTokenUrl(config.getClientId(), config.getClientSecret(), code, config
+ .getRedirectUri());
HttpResponse response = HttpRequest.post(accessTokenUrl).execute();
JSONObject accessTokenObject = JSONObject.parseObject(response.body());
AuthBaiduErrorCode errorCode = AuthBaiduErrorCode.getErrorCode(accessTokenObject.getString("error"));
if (!AuthBaiduErrorCode.OK.equals(errorCode)) {
throw new AuthException(errorCode.getDesc());
}
- return AuthToken.builder()
- .accessToken(accessTokenObject.getString("access_token"))
- .build();
+ return AuthToken.builder().accessToken(accessTokenObject.getString("access_token")).build();
}
@Override
@@ -56,13 +55,23 @@ public class AuthBaiduRequest extends BaseAuthRequest {
.build();
}
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
+ @Override
+ public String authorize() {
+ return UrlBuilder.getBaiduAuthorizeUrl(config.getClientId(), config.getRedirectUri());
+ }
+
@Override
public AuthResponse revoke(AuthToken authToken) {
String accessToken = authToken.getAccessToken();
HttpResponse response = HttpRequest.get(UrlBuilder.getBaiduRevokeUrl(accessToken)).execute();
String userInfo = response.body();
JSONObject object = JSONObject.parseObject(userInfo);
- if(object.containsKey("error_code")) {
+ if (object.containsKey("error_code")) {
return AuthResponse.builder()
.code(ResponseStatus.FAILURE.getCode())
.msg(object.getString("error_msg"))
diff --git a/src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java b/src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java
index 08f397a1d55030324bca9bca5a6b815ae0aaf3fc..66f714353f49d5c793833bcfacab04dbfe1bb127 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.AuthSource;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
@@ -32,9 +32,7 @@ public class AuthCodingRequest extends BaseAuthRequest {
if (accessTokenObject.getIntValue("code") != 0) {
throw new AuthException("Unable to get token from coding using code [" + code + "]");
}
- return AuthToken.builder()
- .accessToken(accessTokenObject.getString("access_token"))
- .build();
+ return AuthToken.builder().accessToken(accessTokenObject.getString("access_token")).build();
}
@Override
@@ -62,4 +60,14 @@ public class AuthCodingRequest extends BaseAuthRequest {
.source(AuthSource.CODING)
.build();
}
+
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
+ @Override
+ public String authorize() {
+ return UrlBuilder.getCodingAuthorizeUrl(config.getClientId(), config.getRedirectUri());
+ }
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java b/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
index b3342317d699ac2f9ffd3559662aebbd34ae7f6f..858441bb1befa8cf340cc9729339217482657f13 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.AuthSource;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
@@ -26,15 +26,14 @@ public class AuthCsdnRequest extends BaseAuthRequest {
@Override
protected AuthToken getAccessToken(String code) {
- String accessTokenUrl = UrlBuilder.getCsdnAccessTokenUrl(config.getClientId(), config.getClientSecret(), code, config.getRedirectUri());
+ String accessTokenUrl = UrlBuilder.getCsdnAccessTokenUrl(config.getClientId(), config.getClientSecret(), code, config
+ .getRedirectUri());
HttpResponse response = HttpRequest.post(accessTokenUrl).execute();
JSONObject accessTokenObject = JSONObject.parseObject(response.body());
if (accessTokenObject.containsKey("error_code")) {
throw new AuthException("Unable to get token from csdn using code [" + code + "]");
}
- return AuthToken.builder()
- .accessToken(accessTokenObject.getString("access_token"))
- .build();
+ return AuthToken.builder().accessToken(accessTokenObject.getString("access_token")).build();
}
@Override
@@ -55,4 +54,14 @@ public class AuthCsdnRequest extends BaseAuthRequest {
.source(AuthSource.CSDN)
.build();
}
+
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
+ @Override
+ public String authorize() {
+ return UrlBuilder.getCsdnAuthorizeUrl(config.getClientId(), config.getRedirectUri());
+ }
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java b/src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java
index d4c236834838dcd2968eb517b56735c1d671dd02..05955e1df1ff7771c46a349d6971c20734e4ef29 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java
@@ -5,8 +5,12 @@ import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.*;
+import me.zhyd.oauth.model.AuthDingTalkErrorCode;
+import me.zhyd.oauth.model.AuthToken;
+import me.zhyd.oauth.model.AuthUser;
+import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.utils.GlobalAuthUtil;
import me.zhyd.oauth.utils.UrlBuilder;
@@ -25,9 +29,7 @@ public class AuthDingTalkRequest extends BaseAuthRequest {
@Override
protected AuthToken getAccessToken(String code) {
- return AuthToken.builder()
- .accessCode(code)
- .build();
+ return AuthToken.builder().accessCode(code).build();
}
@Override
@@ -61,4 +63,14 @@ public class AuthDingTalkRequest extends BaseAuthRequest {
.token(token)
.build();
}
+
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
+ @Override
+ public String authorize() {
+ return UrlBuilder.getDingTalkQrConnectUrl(config.getClientId(), config.getRedirectUri());
+ }
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java b/src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java
index 69754e5dfa3222a407b6601c10e2e57437cf419b..c70c006f881ded2ac5304de4ce3d904c651e23e7 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java
@@ -4,8 +4,12 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.*;
+import me.zhyd.oauth.model.AuthResponse;
+import me.zhyd.oauth.model.AuthToken;
+import me.zhyd.oauth.model.AuthUser;
+import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.utils.UrlBuilder;
@@ -48,6 +52,16 @@ public class AuthDouyinRequest extends BaseAuthRequest {
.build();
}
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
+ @Override
+ public String authorize() {
+ return UrlBuilder.getDouyinAuthorizeUrl(config.getClientId(), config.getRedirectUri());
+ }
+
@Override
public AuthResponse refresh(AuthToken oldToken) {
String refreshTokenUrl = UrlBuilder.getDouyinRefreshUrl(config.getClientId(), oldToken.getRefreshToken());
diff --git a/src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java b/src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java
index 501bfde91acb364c1e1ab8dae4aafec968577ea0..2f8e3c04a85e6d4e952bec0d4da6dc45bd2b52fc 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.AuthSource;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
@@ -26,7 +26,8 @@ public class AuthFacebookRequest extends BaseAuthRequest {
@Override
protected AuthToken getAccessToken(String code) {
- String accessTokenUrl = UrlBuilder.getFacebookAccessTokenUrl(config.getClientId(), config.getClientSecret(), code, config.getRedirectUri());
+ String accessTokenUrl = UrlBuilder.getFacebookAccessTokenUrl(config.getClientId(), config.getClientSecret(), code, config
+ .getRedirectUri());
HttpResponse response = HttpRequest.post(accessTokenUrl).execute();
JSONObject object = JSONObject.parseObject(response.body());
@@ -70,4 +71,14 @@ public class AuthFacebookRequest extends BaseAuthRequest {
.source(AuthSource.FACEBOOK)
.build();
}
+
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
+ @Override
+ public String authorize() {
+ return UrlBuilder.getFacebookAuthorizeUrl(config.getClientId(), config.getRedirectUri());
+ }
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java b/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java
index 1f399627a27752c9736892888b113a4e171682e0..1e3ae3b2398dd2ec322a75273de9a2501399369c 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.AuthSource;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
@@ -26,15 +26,14 @@ public class AuthGiteeRequest extends BaseAuthRequest {
@Override
protected AuthToken getAccessToken(String code) {
- String accessTokenUrl = UrlBuilder.getGiteeAccessTokenUrl(config.getClientId(), config.getClientSecret(), code, config.getRedirectUri());
+ String accessTokenUrl = UrlBuilder.getGiteeAccessTokenUrl(config.getClientId(), config.getClientSecret(), code, config
+ .getRedirectUri());
HttpResponse response = HttpRequest.post(accessTokenUrl).execute();
JSONObject accessTokenObject = JSONObject.parseObject(response.body());
if (accessTokenObject.containsKey("error")) {
throw new AuthException("Unable to get token from gitee using code [" + code + "]");
}
- return AuthToken.builder()
- .accessToken(accessTokenObject.getString("access_token"))
- .build();
+ return AuthToken.builder().accessToken(accessTokenObject.getString("access_token")).build();
}
@Override
@@ -58,4 +57,14 @@ public class AuthGiteeRequest extends BaseAuthRequest {
.source(AuthSource.GITEE)
.build();
}
+
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
+ @Override
+ public String authorize() {
+ return UrlBuilder.getGiteeAuthorizeUrl(config.getClientId(), config.getRedirectUri());
+ }
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java b/src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
index df7c015b7aa687e7ae52afa00e3c22430191e247..db7dcb22748d818d2dd2cad3cd1b556e4836c5ce 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.AuthSource;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
@@ -29,15 +29,14 @@ public class AuthGithubRequest extends BaseAuthRequest {
@Override
protected AuthToken getAccessToken(String code) {
- String accessTokenUrl = UrlBuilder.getGithubAccessTokenUrl(config.getClientId(), config.getClientSecret(), code, config.getRedirectUri());
+ String accessTokenUrl = UrlBuilder.getGithubAccessTokenUrl(config.getClientId(), config.getClientSecret(), code, config
+ .getRedirectUri());
HttpResponse response = HttpRequest.post(accessTokenUrl).execute();
Map res = GlobalAuthUtil.parseStringToMap(response.body());
if (res.containsKey("error")) {
throw new AuthException(res.get("error") + ":" + res.get("error_description"));
}
- return AuthToken.builder()
- .accessToken(res.get("access_token"))
- .build();
+ return AuthToken.builder().accessToken(res.get("access_token")).build();
}
@Override
@@ -61,4 +60,14 @@ public class AuthGithubRequest extends BaseAuthRequest {
.source(AuthSource.GITHUB)
.build();
}
+
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
+ @Override
+ public String authorize() {
+ return UrlBuilder.getGithubAuthorizeUrl(config.getClientId(), config.getRedirectUri());
+ }
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java b/src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java
index fa4527b1f3339c7773e9fc7ba2ecb6e6bf15677b..4e9176151e24eb5583d0a3ee303768306651e313 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.AuthSource;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
@@ -63,4 +63,14 @@ public class AuthGoogleRequest extends BaseAuthRequest {
.source(AuthSource.GOOGLE)
.build();
}
+
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
+ @Override
+ public String authorize() {
+ return UrlBuilder.getGoogleAuthorizeUrl(config.getClientId(), config.getRedirectUri());
+ }
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java b/src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java
index e3bb69a6aae0bd513fa881046c68fb0e20c0ea41..acdb664b525f35bd777506b727878bd78d10a8bd 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java
@@ -5,8 +5,12 @@ import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.*;
+import me.zhyd.oauth.model.AuthResponse;
+import me.zhyd.oauth.model.AuthToken;
+import me.zhyd.oauth.model.AuthUser;
+import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.utils.StringUtils;
import me.zhyd.oauth.utils.UrlBuilder;
@@ -26,7 +30,8 @@ public class AuthLinkedinRequest extends BaseAuthRequest {
@Override
protected AuthToken getAccessToken(String code) {
- String accessTokenUrl = UrlBuilder.getLinkedinAccessTokenUrl(config.getClientId(), config.getClientSecret(), code, config.getRedirectUri());
+ String accessTokenUrl = UrlBuilder.getLinkedinAccessTokenUrl(config.getClientId(), config.getClientSecret(), code, config
+ .getRedirectUri());
return this.getToken(accessTokenUrl);
}
@@ -62,7 +67,8 @@ public class AuthLinkedinRequest extends BaseAuthRequest {
String avatar = null;
JSONObject profilePictureObject = userInfoObject.getJSONObject("profilePicture");
if (profilePictureObject.containsKey("displayImage~")) {
- JSONArray displayImageElements = profilePictureObject.getJSONObject("displayImage~").getJSONArray("elements");
+ JSONArray displayImageElements = profilePictureObject.getJSONObject("displayImage~")
+ .getJSONArray("elements");
if (null != displayImageElements && displayImageElements.size() > 0) {
JSONObject largestImageObj = displayImageElements.getJSONObject(displayImageElements.size() - 1);
avatar = largestImageObj.getJSONArray("identifiers").getJSONObject(0).getString("identifier");
@@ -83,6 +89,16 @@ public class AuthLinkedinRequest extends BaseAuthRequest {
.build();
}
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
+ @Override
+ public String authorize() {
+ return UrlBuilder.getLinkedinAuthorizeUrl(config.getClientId(), config.getRedirectUri());
+ }
+
private String getUserEmail(String accessToken) {
String email = null;
HttpResponse emailResponse = HttpRequest.get("https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))")
@@ -93,7 +109,10 @@ public class AuthLinkedinRequest extends BaseAuthRequest {
System.out.println(emailResponse.body());
JSONObject emailObj = JSONObject.parseObject(emailResponse.body());
if (emailObj.containsKey("elements")) {
- email = emailObj.getJSONArray("elements").getJSONObject(0).getJSONObject("handle~").getString("emailAddress");
+ email = emailObj.getJSONArray("elements")
+ .getJSONObject(0)
+ .getJSONObject("handle~")
+ .getString("emailAddress");
}
return email;
}
@@ -112,7 +131,8 @@ public class AuthLinkedinRequest extends BaseAuthRequest {
if (StringUtils.isEmpty(oldToken.getRefreshToken())) {
throw new AuthException(ResponseStatus.UNSUPPORTED);
}
- String refreshTokenUrl = UrlBuilder.getLinkedinRefreshUrl(config.getClientId(), config.getClientSecret(), oldToken.getRefreshToken());
+ String refreshTokenUrl = UrlBuilder.getLinkedinRefreshUrl(config.getClientId(), config.getClientSecret(), oldToken
+ .getRefreshToken());
return AuthResponse.builder()
.code(ResponseStatus.SUCCESS.getCode())
.data(this.getToken(refreshTokenUrl))
diff --git a/src/main/java/me/zhyd/oauth/request/AuthMiRequest.java b/src/main/java/me/zhyd/oauth/request/AuthMiRequest.java
index 222729a8a922c9488fc51e4c69b08124bf286593..fe404018da277dd502cb8253c313fd6e10c817ae 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthMiRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthMiRequest.java
@@ -5,8 +5,12 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.*;
+import me.zhyd.oauth.model.AuthResponse;
+import me.zhyd.oauth.model.AuthToken;
+import me.zhyd.oauth.model.AuthUser;
+import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.utils.UrlBuilder;
import java.text.MessageFormat;
@@ -90,6 +94,16 @@ public class AuthMiRequest extends BaseAuthRequest {
return authUser;
}
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
+ @Override
+ public String authorize() {
+ return UrlBuilder.getMiAuthorizeUrl(config.getClientId(), config.getRedirectUri());
+ }
+
/**
* 刷新access token (续期)
*
diff --git a/src/main/java/me/zhyd/oauth/request/AuthMicrosoftRequest.java b/src/main/java/me/zhyd/oauth/request/AuthMicrosoftRequest.java
index 83300b1102f58b9f31601b841f47ebe942fd9ed0..8902338b205332e45819378c8ff9ceb5a4ac2b33 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthMicrosoftRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthMicrosoftRequest.java
@@ -5,8 +5,12 @@ import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.*;
+import me.zhyd.oauth.model.AuthResponse;
+import me.zhyd.oauth.model.AuthToken;
+import me.zhyd.oauth.model.AuthUser;
+import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.utils.UrlBuilder;
import java.util.HashMap;
@@ -88,6 +92,16 @@ public class AuthMicrosoftRequest extends BaseAuthRequest {
.build();
}
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
+ @Override
+ public String authorize() {
+ return UrlBuilder.getMicrosoftAuthorizeUrl(config.getClientId(), config.getRedirectUri());
+ }
+
/**
* 刷新access token (续期)
*
diff --git a/src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java b/src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java
index 488e96e140beace25777fe1b269b4976a089901a..0a4d934e096a4dde0cf1a84de2ba29905e763bd3 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.AuthSource;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
@@ -26,15 +26,14 @@ public class AuthOschinaRequest extends BaseAuthRequest {
@Override
protected AuthToken getAccessToken(String code) {
- String accessTokenUrl = UrlBuilder.getOschinaAccessTokenUrl(config.getClientId(), config.getClientSecret(), code, config.getRedirectUri());
+ String accessTokenUrl = UrlBuilder.getOschinaAccessTokenUrl(config.getClientId(), config.getClientSecret(), code, config
+ .getRedirectUri());
HttpResponse response = HttpRequest.post(accessTokenUrl).execute();
JSONObject accessTokenObject = JSONObject.parseObject(response.body());
if (accessTokenObject.containsKey("error")) {
throw new AuthException("Unable to get token from oschina using code [" + code + "]");
}
- return AuthToken.builder()
- .accessToken(accessTokenObject.getString("access_token"))
- .build();
+ return AuthToken.builder().accessToken(accessTokenObject.getString("access_token")).build();
}
@Override
@@ -58,4 +57,14 @@ public class AuthOschinaRequest extends BaseAuthRequest {
.source(AuthSource.OSCHINA)
.build();
}
+
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
+ @Override
+ public String authorize() {
+ return UrlBuilder.getOschinaAuthorizeUrl(config.getClientId(), config.getRedirectUri());
+ }
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java b/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
index e205e322e93d3db3264e91d5e64b9b5df6407f1a..d9ad586eb93970951812f4830a73dc36772d2fc4 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
@@ -5,8 +5,8 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.AuthSource;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
@@ -73,6 +73,16 @@ public class AuthQqRequest extends BaseAuthRequest {
.build();
}
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
+ @Override
+ public String authorize() {
+ return UrlBuilder.getQqAuthorizeUrl(config.getClientId(), config.getRedirectUri());
+ }
+
private String getOpenId(AuthToken authToken) {
String accessToken = authToken.getAccessToken();
HttpResponse response = HttpRequest.get(UrlBuilder.getQqOpenidUrl("https://graph.qq.com/oauth2.0/me", accessToken))
diff --git a/src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java b/src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java
index 56420de3f64423b511318f9633980ab1aa509987..4558597f107a0fb50e19de28171a048976db2a8a 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.AuthSource;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
@@ -27,15 +27,14 @@ public class AuthTaobaoRequest extends BaseAuthRequest {
@Override
protected AuthToken getAccessToken(String code) {
- return AuthToken.builder()
- .accessCode(code)
- .build();
+ return AuthToken.builder().accessCode(code).build();
}
@Override
protected AuthUser getUserInfo(AuthToken authToken) {
String accessCode = authToken.getAccessCode();
- HttpResponse response = HttpRequest.post(UrlBuilder.getTaobaoAccessTokenUrl(this.config.getClientId(), this.config.getClientSecret(), accessCode, this.config.getRedirectUri())).execute();
+ HttpResponse response = HttpRequest.post(UrlBuilder.getTaobaoAccessTokenUrl(this.config.getClientId(), this.config
+ .getClientSecret(), accessCode, this.config.getRedirectUri())).execute();
JSONObject object = JSONObject.parseObject(response.body());
if (object.containsKey("error")) {
throw new AuthException(ResponseStatus.FAILURE + ":" + object.getString("error_description"));
@@ -56,4 +55,14 @@ public class AuthTaobaoRequest extends BaseAuthRequest {
.source(AuthSource.TAOBAO)
.build();
}
+
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
+ @Override
+ public String authorize() {
+ return UrlBuilder.getTaobaoAuthorizeUrl(config.getClientId(), config.getRedirectUri());
+ }
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthTencentCloudRequest.java b/src/main/java/me/zhyd/oauth/request/AuthTencentCloudRequest.java
index 393bd2c74c5076b734491724b7e959b1570ff75e..db4458bbc078d8b4b1b2a3b4bc4a53bbe3db25a4 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthTencentCloudRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthTencentCloudRequest.java
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.AuthSource;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
@@ -32,9 +32,7 @@ public class AuthTencentCloudRequest extends BaseAuthRequest {
if (object.getIntValue("code") != 0) {
throw new AuthException("Unable to get token from tencent cloud using code [" + code + "]: " + object.get("msg"));
}
- return AuthToken.builder()
- .accessToken(object.getString("access_token"))
- .build();
+ return AuthToken.builder().accessToken(object.getString("access_token")).build();
}
@Override
@@ -61,4 +59,14 @@ public class AuthTencentCloudRequest extends BaseAuthRequest {
.source(AuthSource.TENCENT_CLOUD)
.build();
}
+
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
+ @Override
+ public String authorize() {
+ return UrlBuilder.getTencentCloudAuthorizeUrl(config.getClientId(), config.getRedirectUri());
+ }
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthToutiaoRequest.java b/src/main/java/me/zhyd/oauth/request/AuthToutiaoRequest.java
index a193b29029bf25511d15fa62ef51a125fc3dd9c2..423595c8086ae59458b8d9b77c1a9263475e2ec3 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthToutiaoRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthToutiaoRequest.java
@@ -4,8 +4,12 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.*;
+import me.zhyd.oauth.model.AuthToken;
+import me.zhyd.oauth.model.AuthToutiaoErrorCode;
+import me.zhyd.oauth.model.AuthUser;
+import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.utils.UrlBuilder;
/**
@@ -64,4 +68,14 @@ public class AuthToutiaoRequest extends BaseAuthRequest {
.source(AuthSource.TOUTIAO)
.build();
}
+
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
+ @Override
+ public String authorize() {
+ return UrlBuilder.getToutiaoAuthorizeUrl(config.getClientId(), config.getRedirectUri());
+ }
}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java b/src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java
index 6dd4d31ed8685b3429ba01cd12bd66f561cf4587..3d9fb7c4f28d502aba14ea0340b2213ef72e77c8 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthWeChatRequest.java
@@ -4,8 +4,12 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.*;
+import me.zhyd.oauth.model.AuthResponse;
+import me.zhyd.oauth.model.AuthToken;
+import me.zhyd.oauth.model.AuthUser;
+import me.zhyd.oauth.model.AuthUserGender;
import me.zhyd.oauth.utils.UrlBuilder;
/**
@@ -55,6 +59,16 @@ public class AuthWeChatRequest extends BaseAuthRequest {
.build();
}
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
+ @Override
+ public String authorize() {
+ return UrlBuilder.getWeChatAuthorizeUrl(config.getClientId(), config.getRedirectUri());
+ }
+
@Override
public AuthResponse refresh(AuthToken oldToken) {
String refreshTokenUrl = UrlBuilder.getWeChatRefreshUrl(config.getClientId(), oldToken.getRefreshToken());
diff --git a/src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java b/src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
index 6b44ba62d17e05f9d488bbb8ea5127be538d6c3b..be04fb7f956834b07a55db421c330ad9268f308d 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
@@ -4,8 +4,8 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.AuthSource;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.model.AuthUserGender;
@@ -29,7 +29,8 @@ public class AuthWeiboRequest extends BaseAuthRequest {
@Override
protected AuthToken getAccessToken(String code) {
- String accessTokenUrl = UrlBuilder.getWeiboAccessTokenUrl(config.getClientId(), config.getClientSecret(), code, config.getRedirectUri());
+ String accessTokenUrl = UrlBuilder.getWeiboAccessTokenUrl(config.getClientId(), config.getClientSecret(), code, config
+ .getRedirectUri());
HttpResponse response = HttpRequest.post(accessTokenUrl).execute();
String accessTokenStr = response.body();
JSONObject accessTokenObject = JSONObject.parseObject(accessTokenStr);
@@ -70,4 +71,14 @@ public class AuthWeiboRequest extends BaseAuthRequest {
.source(AuthSource.WEIBO)
.build();
}
+
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
+ @Override
+ public String authorize() {
+ return UrlBuilder.getWeiboAuthorizeUrl(config.getClientId(), config.getRedirectUri());
+ }
}
diff --git a/src/main/java/me/zhyd/oauth/request/BaseAuthRequest.java b/src/main/java/me/zhyd/oauth/request/BaseAuthRequest.java
index b0f6f82b66997403a3446156d5b1a8747e572e8e..4fa29c3a7d158df25cbf39bbdf13eb8c387ed673 100644
--- a/src/main/java/me/zhyd/oauth/request/BaseAuthRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/BaseAuthRequest.java
@@ -1,11 +1,10 @@
package me.zhyd.oauth.request;
import lombok.Data;
-import me.zhyd.oauth.authorization.AuthorizationFactory;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.AuthResponse;
-import me.zhyd.oauth.model.AuthSource;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.utils.AuthConfigChecker;
@@ -53,8 +52,11 @@ public abstract class BaseAuthRequest implements AuthRequest {
return AuthResponse.builder().code(errorCode).msg(e.getMessage()).build();
}
+ /**
+ * 返回认证url,可自行跳转页面
+ *
+ * @return 返回授权地址
+ */
@Override
- public String authorize() {
- return AuthorizationFactory.getAuthorize(source).getAuthorizeUrl(config);
- }
+ public abstract String authorize();
}
diff --git a/src/main/java/me/zhyd/oauth/utils/AuthConfigChecker.java b/src/main/java/me/zhyd/oauth/utils/AuthConfigChecker.java
index c05b04ed4626b5e8c5597b2b9a7add527e251dca..5451d48bfe0e275e2add16fba7e985edbf2927b2 100644
--- a/src/main/java/me/zhyd/oauth/utils/AuthConfigChecker.java
+++ b/src/main/java/me/zhyd/oauth/utils/AuthConfigChecker.java
@@ -1,8 +1,8 @@
package me.zhyd.oauth.utils;
import me.zhyd.oauth.config.AuthConfig;
+import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
-import me.zhyd.oauth.model.AuthSource;
import me.zhyd.oauth.request.ResponseStatus;
/**
diff --git a/src/main/java/me/zhyd/oauth/utils/UrlBuilder.java b/src/main/java/me/zhyd/oauth/utils/UrlBuilder.java
index db66917c1ae504fa91e4461cef9192d12a1f9d5d..b48249979a8f6f9e6a0423e5007a1c0fb9087835 100644
--- a/src/main/java/me/zhyd/oauth/utils/UrlBuilder.java
+++ b/src/main/java/me/zhyd/oauth/utils/UrlBuilder.java
@@ -1,6 +1,6 @@
package me.zhyd.oauth.utils;
-import me.zhyd.oauth.consts.ApiUrl;
+import me.zhyd.oauth.config.AuthSource;
import java.text.MessageFormat;
@@ -106,7 +106,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getGithubAccessTokenUrl(String clientId, String clientSecret, String code, String redirectUri) {
- return MessageFormat.format(GITHUB_ACCESS_TOKEN_PATTERN, ApiUrl.GITHUB.accessToken(), clientId, clientSecret, code, redirectUri);
+ return MessageFormat.format(GITHUB_ACCESS_TOKEN_PATTERN, AuthSource.GITHUB.accessToken(), clientId, clientSecret, code, redirectUri);
}
/**
@@ -116,7 +116,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getGithubUserInfoUrl(String token) {
- return MessageFormat.format(GITHUB_USER_INFO_PATTERN, ApiUrl.GITHUB.userInfo(), token);
+ return MessageFormat.format(GITHUB_USER_INFO_PATTERN, AuthSource.GITHUB.userInfo(), token);
}
/**
@@ -127,7 +127,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getGithubAuthorizeUrl(String clientId, String redirectUrl) {
- return MessageFormat.format(GITHUB_AUTHORIZE_PATTERN, ApiUrl.GITHUB.authorize(), clientId, redirectUrl);
+ return MessageFormat.format(GITHUB_AUTHORIZE_PATTERN, AuthSource.GITHUB.authorize(), clientId, redirectUrl);
}
/**
@@ -140,7 +140,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getWeiboAccessTokenUrl(String clientId, String clientSecret, String code, String redirectUri) {
- return MessageFormat.format(WEIBO_ACCESS_TOKEN_PATTERN, ApiUrl.WEIBO.accessToken(), clientId, clientSecret, code, redirectUri);
+ return MessageFormat.format(WEIBO_ACCESS_TOKEN_PATTERN, AuthSource.WEIBO.accessToken(), clientId, clientSecret, code, redirectUri);
}
/**
@@ -150,7 +150,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getWeiboUserInfoUrl(String token) {
- return MessageFormat.format(WEIBO_USER_INFO_PATTERN, ApiUrl.WEIBO.userInfo(), token);
+ return MessageFormat.format(WEIBO_USER_INFO_PATTERN, AuthSource.WEIBO.userInfo(), token);
}
/**
@@ -161,7 +161,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getWeiboAuthorizeUrl(String clientId, String redirectUrl) {
- return MessageFormat.format(WEIBO_AUTHORIZE_PATTERN, ApiUrl.WEIBO.authorize(), clientId, redirectUrl);
+ return MessageFormat.format(WEIBO_AUTHORIZE_PATTERN, AuthSource.WEIBO.authorize(), clientId, redirectUrl);
}
/**
@@ -174,7 +174,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getGiteeAccessTokenUrl(String clientId, String clientSecret, String code, String redirectUri) {
- return MessageFormat.format(GITEE_ACCESS_TOKEN_PATTERN, ApiUrl.GITEE.accessToken(), clientId, clientSecret, code, redirectUri);
+ return MessageFormat.format(GITEE_ACCESS_TOKEN_PATTERN, AuthSource.GITEE.accessToken(), clientId, clientSecret, code, redirectUri);
}
/**
@@ -184,7 +184,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getGiteeUserInfoUrl(String token) {
- return MessageFormat.format(GITEE_USER_INFO_PATTERN, ApiUrl.GITEE.userInfo(), token);
+ return MessageFormat.format(GITEE_USER_INFO_PATTERN, AuthSource.GITEE.userInfo(), token);
}
/**
@@ -195,7 +195,7 @@ public class UrlBuilder {
* @return json
*/
public static String getGiteeAuthorizeUrl(String clientId, String redirectUrl) {
- return MessageFormat.format(GITEE_AUTHORIZE_PATTERN, ApiUrl.GITEE.authorize(), clientId, redirectUrl);
+ return MessageFormat.format(GITEE_AUTHORIZE_PATTERN, AuthSource.GITEE.authorize(), clientId, redirectUrl);
}
/**
@@ -206,7 +206,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getDingTalkQrConnectUrl(String clientId, String redirectUrl) {
- return MessageFormat.format(DING_TALK_QRCONNECT_PATTERN, ApiUrl.DINGTALK.authorize(), clientId, redirectUrl);
+ return MessageFormat.format(DING_TALK_QRCONNECT_PATTERN, AuthSource.DINGTALK.authorize(), clientId, redirectUrl);
}
/**
@@ -218,7 +218,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getDingTalkUserInfoUrl(String signature, String timestamp, String accessKey) {
- return MessageFormat.format(DING_TALK_USER_INFO_PATTERN, ApiUrl.DINGTALK.userInfo(), signature, timestamp, accessKey);
+ return MessageFormat.format(DING_TALK_USER_INFO_PATTERN, AuthSource.DINGTALK.userInfo(), signature, timestamp, accessKey);
}
/**
@@ -231,7 +231,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getBaiduAccessTokenUrl(String clientId, String clientSecret, String code, String redirectUri) {
- return MessageFormat.format(BAIDU_ACCESS_TOKEN_PATTERN, ApiUrl.BAIDU.accessToken(), clientId, clientSecret, code, redirectUri);
+ return MessageFormat.format(BAIDU_ACCESS_TOKEN_PATTERN, AuthSource.BAIDU.accessToken(), clientId, clientSecret, code, redirectUri);
}
/**
@@ -241,7 +241,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getBaiduUserInfoUrl(String token) {
- return MessageFormat.format(BAIDU_USER_INFO_PATTERN, ApiUrl.BAIDU.userInfo(), token);
+ return MessageFormat.format(BAIDU_USER_INFO_PATTERN, AuthSource.BAIDU.userInfo(), token);
}
/**
@@ -252,7 +252,7 @@ public class UrlBuilder {
* @return json
*/
public static String getBaiduAuthorizeUrl(String clientId, String redirectUrl) {
- return MessageFormat.format(BAIDU_AUTHORIZE_PATTERN, ApiUrl.BAIDU.authorize(), clientId, redirectUrl);
+ return MessageFormat.format(BAIDU_AUTHORIZE_PATTERN, AuthSource.BAIDU.authorize(), clientId, redirectUrl);
}
/**
@@ -262,7 +262,7 @@ public class UrlBuilder {
* @return json
*/
public static String getBaiduRevokeUrl(String accessToken) {
- return MessageFormat.format(BAIDU_REVOKE_PATTERN, ApiUrl.BAIDU.revoke(), accessToken);
+ return MessageFormat.format(BAIDU_REVOKE_PATTERN, AuthSource.BAIDU.revoke(), accessToken);
}
/**
@@ -275,7 +275,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getCsdnAccessTokenUrl(String clientId, String clientSecret, String code, String redirectUri) {
- return MessageFormat.format(CSDN_ACCESS_TOKEN_PATTERN, ApiUrl.CSDN.accessToken(), clientId, clientSecret, code, redirectUri);
+ return MessageFormat.format(CSDN_ACCESS_TOKEN_PATTERN, AuthSource.CSDN.accessToken(), clientId, clientSecret, code, redirectUri);
}
/**
@@ -285,7 +285,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getCsdnUserInfoUrl(String token) {
- return MessageFormat.format(CSDN_USER_INFO_PATTERN, ApiUrl.CSDN.userInfo(), token);
+ return MessageFormat.format(CSDN_USER_INFO_PATTERN, AuthSource.CSDN.userInfo(), token);
}
/**
@@ -296,7 +296,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getCsdnAuthorizeUrl(String clientId, String redirectUrl) {
- return MessageFormat.format(CSDN_AUTHORIZE_PATTERN, ApiUrl.CSDN.authorize(), clientId, redirectUrl);
+ return MessageFormat.format(CSDN_AUTHORIZE_PATTERN, AuthSource.CSDN.authorize(), clientId, redirectUrl);
}
/**
@@ -308,7 +308,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getCodingAccessTokenUrl(String clientId, String clientSecret, String code) {
- return MessageFormat.format(CODING_ACCESS_TOKEN_PATTERN, ApiUrl.CODING.accessToken(), clientId, clientSecret, code);
+ return MessageFormat.format(CODING_ACCESS_TOKEN_PATTERN, AuthSource.CODING.accessToken(), clientId, clientSecret, code);
}
/**
@@ -318,7 +318,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getCodingUserInfoUrl(String token) {
- return MessageFormat.format(CODING_USER_INFO_PATTERN, ApiUrl.CODING.userInfo(), token);
+ return MessageFormat.format(CODING_USER_INFO_PATTERN, AuthSource.CODING.userInfo(), token);
}
/**
@@ -329,7 +329,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getCodingAuthorizeUrl(String clientId, String redirectUrl) {
- return MessageFormat.format(CODING_AUTHORIZE_PATTERN, ApiUrl.CODING.authorize(), clientId, redirectUrl);
+ return MessageFormat.format(CODING_AUTHORIZE_PATTERN, AuthSource.CODING.authorize(), clientId, redirectUrl);
}
/**
@@ -341,7 +341,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getTencentCloudAccessTokenUrl(String clientId, String clientSecret, String code) {
- return MessageFormat.format(TENCENT_ACCESS_TOKEN_PATTERN, ApiUrl.TENCENTCLOUD.accessToken(), clientId, clientSecret, code);
+ return MessageFormat.format(TENCENT_ACCESS_TOKEN_PATTERN, AuthSource.TENCENT_CLOUD.accessToken(), clientId, clientSecret, code);
}
/**
@@ -351,7 +351,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getTencentCloudUserInfoUrl(String token) {
- return MessageFormat.format(TENCENT_USER_INFO_PATTERN, ApiUrl.TENCENTCLOUD.userInfo(), token);
+ return MessageFormat.format(TENCENT_USER_INFO_PATTERN, AuthSource.TENCENT_CLOUD.userInfo(), token);
}
/**
@@ -362,7 +362,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getTencentCloudAuthorizeUrl(String clientId, String redirectUrl) {
- return MessageFormat.format(TENCENT_AUTHORIZE_PATTERN, ApiUrl.TENCENTCLOUD.authorize(), clientId, redirectUrl);
+ return MessageFormat.format(TENCENT_AUTHORIZE_PATTERN, AuthSource.TENCENT_CLOUD.authorize(), clientId, redirectUrl);
}
/**
@@ -375,7 +375,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getOschinaAccessTokenUrl(String clientId, String clientSecret, String code, String redirectUri) {
- return MessageFormat.format(OSCHINA_ACCESS_TOKEN_PATTERN, ApiUrl.OSCHINA.accessToken(), clientId, clientSecret, code, redirectUri);
+ return MessageFormat.format(OSCHINA_ACCESS_TOKEN_PATTERN, AuthSource.OSCHINA.accessToken(), clientId, clientSecret, code, redirectUri);
}
/**
@@ -385,7 +385,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getOschinaUserInfoUrl(String token) {
- return MessageFormat.format(OSCHINA_USER_INFO_PATTERN, ApiUrl.OSCHINA.userInfo(), token);
+ return MessageFormat.format(OSCHINA_USER_INFO_PATTERN, AuthSource.OSCHINA.userInfo(), token);
}
/**
@@ -396,7 +396,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getOschinaAuthorizeUrl(String clientId, String redirectUrl) {
- return MessageFormat.format(OSCHINA_AUTHORIZE_PATTERN, ApiUrl.OSCHINA.authorize(), clientId, redirectUrl);
+ return MessageFormat.format(OSCHINA_AUTHORIZE_PATTERN, AuthSource.OSCHINA.authorize(), clientId, redirectUrl);
}
/**
@@ -409,7 +409,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getQqAccessTokenUrl(String clientId, String clientSecret, String code, String redirectUri) {
- return MessageFormat.format(QQ_ACCESS_TOKEN_PATTERN, ApiUrl.QQ.accessToken(), clientId, clientSecret, code, redirectUri);
+ return MessageFormat.format(QQ_ACCESS_TOKEN_PATTERN, AuthSource.QQ.accessToken(), clientId, clientSecret, code, redirectUri);
}
/**
@@ -421,7 +421,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getQqUserInfoUrl(String clientId, String token, String openId) {
- return MessageFormat.format(QQ_USER_INFO_PATTERN, ApiUrl.QQ.userInfo(), clientId, token, openId);
+ return MessageFormat.format(QQ_USER_INFO_PATTERN, AuthSource.QQ.userInfo(), clientId, token, openId);
}
/**
@@ -432,7 +432,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getQqAuthorizeUrl(String clientId, String redirectUrl) {
- return MessageFormat.format(QQ_AUTHORIZE_PATTERN, ApiUrl.QQ.authorize(), clientId, redirectUrl, System.currentTimeMillis());
+ return MessageFormat.format(QQ_AUTHORIZE_PATTERN, AuthSource.QQ.authorize(), clientId, redirectUrl, System.currentTimeMillis());
}
/**
@@ -454,7 +454,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getAlipayAuthorizeUrl(String clientId, String redirectUrl) {
- return MessageFormat.format(ALIPAY_AUTHORIZE_PATTERN, ApiUrl.ALIPAY.authorize(), clientId, redirectUrl);
+ return MessageFormat.format(ALIPAY_AUTHORIZE_PATTERN, AuthSource.ALIPAY.authorize(), clientId, redirectUrl);
}
/**
@@ -465,7 +465,8 @@ public class UrlBuilder {
* @return full url
*/
public static String getWeChatAuthorizeUrl(String clientId, String redirectUrl) {
- return MessageFormat.format(WECHAT_AUTHORIZE_PATTERN, ApiUrl.WECHAT.authorize(), clientId, redirectUrl, System.currentTimeMillis());
+ return MessageFormat.format(WECHAT_AUTHORIZE_PATTERN, AuthSource.WECHAT.authorize(), clientId, redirectUrl, System
+ .currentTimeMillis());
}
/**
@@ -477,7 +478,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getWeChatAccessTokenUrl(String clientId, String clientSecret, String code) {
- return MessageFormat.format(WECHAT_ACCESS_TOKEN_PATTERN, ApiUrl.WECHAT.accessToken(), clientId, clientSecret, code);
+ return MessageFormat.format(WECHAT_ACCESS_TOKEN_PATTERN, AuthSource.WECHAT.accessToken(), clientId, clientSecret, code);
}
/**
@@ -488,7 +489,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getWeChatUserInfoUrl(String token, String openId) {
- return MessageFormat.format(WECHAT_USER_INFO_PATTERN, ApiUrl.WECHAT.userInfo(), token, openId);
+ return MessageFormat.format(WECHAT_USER_INFO_PATTERN, AuthSource.WECHAT.userInfo(), token, openId);
}
/**
@@ -499,7 +500,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getWeChatRefreshUrl(String clientId, String refreshToken) {
- return MessageFormat.format(WECHAT_REFRESH_TOKEN_PATTERN, ApiUrl.WECHAT.refresh(), clientId, refreshToken);
+ return MessageFormat.format(WECHAT_REFRESH_TOKEN_PATTERN, AuthSource.WECHAT.refresh(), clientId, refreshToken);
}
/**
@@ -512,7 +513,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getTaobaoAccessTokenUrl(String clientId, String clientSecret, String code, String redirectUri) {
- return MessageFormat.format(TAOBAO_ACCESS_TOKEN_PATTERN, ApiUrl.TAOBAO.accessToken(), clientId, clientSecret, code, redirectUri);
+ return MessageFormat.format(TAOBAO_ACCESS_TOKEN_PATTERN, AuthSource.TAOBAO.accessToken(), clientId, clientSecret, code, redirectUri);
}
/**
@@ -523,7 +524,8 @@ public class UrlBuilder {
* @return full url
*/
public static String getTaobaoAuthorizeUrl(String clientId, String redirectUrl) {
- return MessageFormat.format(TAOBAO_AUTHORIZE_PATTERN, ApiUrl.TAOBAO.authorize(), clientId, redirectUrl, System.currentTimeMillis());
+ return MessageFormat.format(TAOBAO_AUTHORIZE_PATTERN, AuthSource.TAOBAO.authorize(), clientId, redirectUrl, System
+ .currentTimeMillis());
}
/**
@@ -534,7 +536,8 @@ public class UrlBuilder {
* @return full url
*/
public static String getGoogleAuthorizeUrl(String clientId, String redirectUrl) {
- return MessageFormat.format(GOOGLE_AUTHORIZE_PATTERN, ApiUrl.GOOGLE.authorize(), clientId, redirectUrl, System.currentTimeMillis());
+ return MessageFormat.format(GOOGLE_AUTHORIZE_PATTERN, AuthSource.GOOGLE.authorize(), clientId, redirectUrl, System
+ .currentTimeMillis());
}
/**
@@ -547,7 +550,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getGoogleAccessTokenUrl(String clientId, String clientSecret, String code, String redirectUri) {
- return MessageFormat.format(GOOGLE_ACCESS_TOKEN_PATTERN, ApiUrl.GOOGLE.accessToken(), clientId, clientSecret, code, redirectUri);
+ return MessageFormat.format(GOOGLE_ACCESS_TOKEN_PATTERN, AuthSource.GOOGLE.accessToken(), clientId, clientSecret, code, redirectUri);
}
/**
@@ -557,7 +560,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getGoogleUserInfoUrl(String token) {
- return MessageFormat.format(GOOGLE_USER_INFO_PATTERN, ApiUrl.GOOGLE.userInfo(), token);
+ return MessageFormat.format(GOOGLE_USER_INFO_PATTERN, AuthSource.GOOGLE.userInfo(), token);
}
/**
@@ -568,7 +571,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getFacebookAuthorizeUrl(String clientId, String redirectUrl) {
- return MessageFormat.format(FACEBOOK_AUTHORIZE_PATTERN, ApiUrl.FACEBOOK.authorize(), clientId, redirectUrl, System
+ return MessageFormat.format(FACEBOOK_AUTHORIZE_PATTERN, AuthSource.FACEBOOK.authorize(), clientId, redirectUrl, System
.currentTimeMillis());
}
@@ -582,7 +585,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getFacebookAccessTokenUrl(String clientId, String clientSecret, String code, String redirectUri) {
- return MessageFormat.format(FACEBOOK_ACCESS_TOKEN_PATTERN, ApiUrl.FACEBOOK.accessToken(), clientId, clientSecret, code, redirectUri);
+ return MessageFormat.format(FACEBOOK_ACCESS_TOKEN_PATTERN, AuthSource.FACEBOOK.accessToken(), clientId, clientSecret, code, redirectUri);
}
/**
@@ -592,7 +595,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getFacebookUserInfoUrl(String token) {
- return MessageFormat.format(FACEBOOK_USER_INFO_PATTERN, ApiUrl.FACEBOOK.userInfo(), token);
+ return MessageFormat.format(FACEBOOK_USER_INFO_PATTERN, AuthSource.FACEBOOK.userInfo(), token);
}
/**
@@ -603,7 +606,8 @@ public class UrlBuilder {
* @return full url
*/
public static String getDouyinAuthorizeUrl(String clientId, String redirectUrl) {
- return MessageFormat.format(DOUYIN_AUTHORIZE_PATTERN, ApiUrl.DOUYIN.authorize(), clientId, redirectUrl, System.currentTimeMillis());
+ return MessageFormat.format(DOUYIN_AUTHORIZE_PATTERN, AuthSource.DOUYIN.authorize(), clientId, redirectUrl, System
+ .currentTimeMillis());
}
/**
@@ -615,7 +619,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getDouyinAccessTokenUrl(String clientId, String clientSecret, String code) {
- return MessageFormat.format(DOUYIN_ACCESS_TOKEN_PATTERN, ApiUrl.DOUYIN.accessToken(), clientId, clientSecret, code);
+ return MessageFormat.format(DOUYIN_ACCESS_TOKEN_PATTERN, AuthSource.DOUYIN.accessToken(), clientId, clientSecret, code);
}
/**
@@ -626,7 +630,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getDouyinUserInfoUrl(String token, String openId) {
- return MessageFormat.format(DOUYIN_USER_INFO_PATTERN, ApiUrl.DOUYIN.userInfo(), token, openId);
+ return MessageFormat.format(DOUYIN_USER_INFO_PATTERN, AuthSource.DOUYIN.userInfo(), token, openId);
}
/**
@@ -637,7 +641,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getDouyinRefreshUrl(String clientId, String refreshToken) {
- return MessageFormat.format(DOUYIN_REFRESH_TOKEN_PATTERN, ApiUrl.DOUYIN.refresh(), clientId, refreshToken);
+ return MessageFormat.format(DOUYIN_REFRESH_TOKEN_PATTERN, AuthSource.DOUYIN.refresh(), clientId, refreshToken);
}
/**
@@ -648,7 +652,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getLinkedinAuthorizeUrl(String clientId, String redirectUrl) {
- return MessageFormat.format(LINKEDIN_AUTHORIZE_PATTERN, ApiUrl.LINKEDIN.authorize(), clientId, redirectUrl, System
+ return MessageFormat.format(LINKEDIN_AUTHORIZE_PATTERN, AuthSource.LINKEDIN.authorize(), clientId, redirectUrl, System
.currentTimeMillis());
}
@@ -662,7 +666,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getLinkedinAccessTokenUrl(String clientId, String clientSecret, String code, String redirectUrl) {
- return MessageFormat.format(LINKEDIN_ACCESS_TOKEN_PATTERN, ApiUrl.LINKEDIN.accessToken(), clientId, clientSecret, code, redirectUrl);
+ return MessageFormat.format(LINKEDIN_ACCESS_TOKEN_PATTERN, AuthSource.LINKEDIN.accessToken(), clientId, clientSecret, code, redirectUrl);
}
/**
@@ -671,7 +675,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getLinkedinUserInfoUrl() {
- return MessageFormat.format(LINKEDIN_USER_INFO_PATTERN, ApiUrl.LINKEDIN.userInfo());
+ return MessageFormat.format(LINKEDIN_USER_INFO_PATTERN, AuthSource.LINKEDIN.userInfo());
}
/**
@@ -683,7 +687,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getLinkedinRefreshUrl(String clientId, String clientSecret, String refreshToken) {
- return MessageFormat.format(LINKEDIN_REFRESH_TOKEN_PATTERN, ApiUrl.LINKEDIN.refresh(), clientId, clientSecret, refreshToken);
+ return MessageFormat.format(LINKEDIN_REFRESH_TOKEN_PATTERN, AuthSource.LINKEDIN.refresh(), clientId, clientSecret, refreshToken);
}
/**
@@ -694,7 +698,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getMicrosoftAuthorizeUrl(String clientId, String redirectUrl) {
- return MessageFormat.format(MICROSOFT_AUTHORIZE_PATTERN, ApiUrl.MICROSOFT.authorize(), clientId, redirectUrl, System
+ return MessageFormat.format(MICROSOFT_AUTHORIZE_PATTERN, AuthSource.MICROSOFT.authorize(), clientId, redirectUrl, System
.currentTimeMillis());
}
@@ -708,7 +712,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getMicrosoftAccessTokenUrl(String clientId, String clientSecret, String redirectUrl, String code) {
- return MessageFormat.format(MICROSOFT_ACCESS_TOKEN_PATTERN, ApiUrl.MICROSOFT.accessToken(), clientId, clientSecret, redirectUrl, code);
+ return MessageFormat.format(MICROSOFT_ACCESS_TOKEN_PATTERN, AuthSource.MICROSOFT.accessToken(), clientId, clientSecret, redirectUrl, code);
}
/**
@@ -717,7 +721,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getMicrosoftUserInfoUrl() {
- return MessageFormat.format(MICROSOFT_USER_INFO_PATTERN, ApiUrl.MICROSOFT.userInfo());
+ return MessageFormat.format(MICROSOFT_USER_INFO_PATTERN, AuthSource.MICROSOFT.userInfo());
}
/**
@@ -730,7 +734,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getMicrosoftRefreshUrl(String clientId, String clientSecret, String redirectUrl, String refreshToken) {
- return MessageFormat.format(MICROSOFT_REFRESH_TOKEN_PATTERN, ApiUrl.MICROSOFT.refresh(), clientId, clientSecret, redirectUrl, refreshToken);
+ return MessageFormat.format(MICROSOFT_REFRESH_TOKEN_PATTERN, AuthSource.MICROSOFT.refresh(), clientId, clientSecret, redirectUrl, refreshToken);
}
/**
@@ -741,7 +745,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getMiAuthorizeUrl(String clientId, String redirectUrl) {
- return MessageFormat.format(MI_AUTHORIZE_PATTERN, ApiUrl.MI.authorize(), clientId, redirectUrl, System.currentTimeMillis());
+ return MessageFormat.format(MI_AUTHORIZE_PATTERN, AuthSource.MI.authorize(), clientId, redirectUrl, System.currentTimeMillis());
}
/**
@@ -754,7 +758,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getMiAccessTokenUrl(String clientId, String clientSecret, String redirectUrl, String code) {
- return MessageFormat.format(MI_ACCESS_TOKEN_PATTERN, ApiUrl.MI.accessToken(), clientId, clientSecret, redirectUrl, code);
+ return MessageFormat.format(MI_ACCESS_TOKEN_PATTERN, AuthSource.MI.accessToken(), clientId, clientSecret, redirectUrl, code);
}
/**
@@ -765,7 +769,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getMiUserInfoUrl(String clientId, String token) {
- return MessageFormat.format(MI_USER_INFO_PATTERN, ApiUrl.MI.userInfo(), clientId, token);
+ return MessageFormat.format(MI_USER_INFO_PATTERN, AuthSource.MI.userInfo(), clientId, token);
}
/**
@@ -778,7 +782,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getMiRefreshUrl(String clientId, String clientSecret, String redirectUrl, String refreshToken) {
- return MessageFormat.format(MI_REFRESH_TOKEN_PATTERN, ApiUrl.MI.refresh(), clientId, clientSecret, redirectUrl, refreshToken);
+ return MessageFormat.format(MI_REFRESH_TOKEN_PATTERN, AuthSource.MI.refresh(), clientId, clientSecret, redirectUrl, refreshToken);
}
/**
@@ -789,7 +793,8 @@ public class UrlBuilder {
* @return full url
*/
public static String getToutiaoAuthorizeUrl(String clientId, String redirectUrl) {
- return MessageFormat.format(TOUTIAO_AUTHORIZE_PATTERN, ApiUrl.TOUTIAO.authorize(), clientId, redirectUrl, System.currentTimeMillis());
+ return MessageFormat.format(TOUTIAO_AUTHORIZE_PATTERN, AuthSource.TOUTIAO.authorize(), clientId, redirectUrl, System
+ .currentTimeMillis());
}
/**
@@ -801,7 +806,7 @@ public class UrlBuilder {
* @return full url
*/
public static String getToutiaoAccessTokenUrl(String clientId, String clientSecret, String code) {
- return MessageFormat.format(TOUTIAO_ACCESS_TOKEN_PATTERN, ApiUrl.TOUTIAO.accessToken(), clientId, clientSecret, code);
+ return MessageFormat.format(TOUTIAO_ACCESS_TOKEN_PATTERN, AuthSource.TOUTIAO.accessToken(), clientId, clientSecret, code);
}
/**
@@ -812,6 +817,6 @@ public class UrlBuilder {
* @return full url
*/
public static String getToutiaoUserInfoUrl(String clientId, String token) {
- return MessageFormat.format(TOUTIAO_USER_INFO_PATTERN, ApiUrl.TOUTIAO.userInfo(), clientId, token);
+ return MessageFormat.format(TOUTIAO_USER_INFO_PATTERN, AuthSource.TOUTIAO.userInfo(), clientId, token);
}
}
diff --git a/update.md b/update.md
index 0b58011f39e7af6458e38f7351778e77dae77221..9183d2d5dbb9e29715414c8a3b2421b21c20e11b 100644
--- a/update.md
+++ b/update.md
@@ -1,10 +1,13 @@
-### 2019/06/18
+### 2019/06/19
+1. 合并[xkcoding](https://github.com/xkcoding)提交的[PR](https://github.com/zhangyd-c/JustAuth/pull/14),重构了部分代码,jar包由原来的`130+kb`优化到现在的`110+kb`
+
+### 2019/06/18
1. 解决Issue [#IY2HW](https://gitee.com/yadong.zhang/JustAuth/issues/IY2HW)
2. 解决Issue [#IY2OH](https://gitee.com/yadong.zhang/JustAuth/issues/IY2OH)
3. 解决Issue [#IY2FV](https://gitee.com/yadong.zhang/JustAuth/issues/IY2FV)
4. 修复部分注释、拼写错误
5. 解决Issue [#IY1QR](https://gitee.com/yadong.zhang/JustAuth/issues/IY1QR) 增加对Config属性的校验功能,主要校验redirect uri的合法性
-6. 合并[skqing](https://gitee.com/skqing)提交的[PR](https://gitee.com/yadong.zhang/JustAuth/pulls/2)
+6. 合并[skqing](https://gitee.com/skqing)提交的[PR](https://gitee.com/yadong.zhang/JustAuth/pulls/2),解决一些BUG
### 2019/06/06
1. 增加今日头条的授权登陆