diff --git a/src/main/java/me/zhyd/oauth/request/AbstractAuthDingtalkRequest.java b/src/main/java/me/zhyd/oauth/request/AbstractAuthDingtalkRequest.java index b331e786..541e202b 100644 --- a/src/main/java/me/zhyd/oauth/request/AbstractAuthDingtalkRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AbstractAuthDingtalkRequest.java @@ -34,12 +34,12 @@ public AbstractAuthDingtalkRequest(AuthConfig config, AuthSource source, AuthSta } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { return AuthToken.builder().accessCode(authCallback.getCode()).build(); } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String code = authToken.getAccessCode(); JSONObject param = new JSONObject(); param.put("tmp_auth_code", code); diff --git a/src/main/java/me/zhyd/oauth/request/AbstractAuthMicrosoftRequest.java b/src/main/java/me/zhyd/oauth/request/AbstractAuthMicrosoftRequest.java index d8f0200e..c1d98de3 100644 --- a/src/main/java/me/zhyd/oauth/request/AbstractAuthMicrosoftRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AbstractAuthMicrosoftRequest.java @@ -39,7 +39,7 @@ public AbstractAuthMicrosoftRequest(AuthConfig config, AuthSource source, AuthSt } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { return getToken(accessTokenUrl(authCallback.getCode())); } @@ -80,7 +80,7 @@ private void checkResponse(JSONObject object) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String token = authToken.getAccessToken(); String tokenType = authToken.getTokenType(); String jwt = tokenType + " " + token; diff --git a/src/main/java/me/zhyd/oauth/request/AbstractAuthWeChatEnterpriseRequest.java b/src/main/java/me/zhyd/oauth/request/AbstractAuthWeChatEnterpriseRequest.java index a2105cf2..9fd80677 100644 --- a/src/main/java/me/zhyd/oauth/request/AbstractAuthWeChatEnterpriseRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AbstractAuthWeChatEnterpriseRequest.java @@ -34,7 +34,7 @@ public AbstractAuthWeChatEnterpriseRequest(AuthConfig config, AuthSource source, } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { String response = doGetAuthorizationCode(accessTokenUrl(null)); JSONObject object = this.checkResponse(response); @@ -47,7 +47,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String response = doGetUserInfo(authToken); JSONObject object = this.checkResponse(response); diff --git a/src/main/java/me/zhyd/oauth/request/AuthAfDianRequest.java b/src/main/java/me/zhyd/oauth/request/AuthAfDianRequest.java index b30385e2..65780773 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthAfDianRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthAfDianRequest.java @@ -30,7 +30,7 @@ public AuthAfDianRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { Map params = new HashMap<>(); params.put("grant_type", "authorization_code"); params.put("client_id", config.getClientId()); @@ -44,7 +44,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { return AuthUser.builder() .uuid(authToken.getUserId()) .gender(AuthUserGender.UNKNOWN) diff --git a/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java b/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java index 04aa0bc7..b8323468 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java @@ -147,7 +147,7 @@ protected void checkCode(AuthCallback authCallback) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest(); request.setGrantType("authorization_code"); request.setCode(authCallback.getAuth_code()); @@ -200,7 +200,7 @@ public AuthResponse refresh(AuthToken authToken) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String accessToken = authToken.getAccessToken(); AlipayUserInfoShareRequest request = new AlipayUserInfoShareRequest(); AlipayUserInfoShareResponse response = null; diff --git a/src/main/java/me/zhyd/oauth/request/AuthAliyunRequest.java b/src/main/java/me/zhyd/oauth/request/AuthAliyunRequest.java index 9d4f98fe..2651612f 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthAliyunRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthAliyunRequest.java @@ -26,7 +26,7 @@ public AuthAliyunRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { String response = doPostAuthorizationCode(authCallback.getCode()); JSONObject accessTokenObject = JSONObject.parseObject(response); return AuthToken.builder() @@ -39,7 +39,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String userInfo = doGetUserInfo(authToken); JSONObject object = JSONObject.parseObject(userInfo); return AuthUser.builder() diff --git a/src/main/java/me/zhyd/oauth/request/AuthAmazonRequest.java b/src/main/java/me/zhyd/oauth/request/AuthAmazonRequest.java index 78a60044..b4c70bcf 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthAmazonRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthAmazonRequest.java @@ -77,7 +77,7 @@ public String authorize(String state) { * @return access token */ @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { Map form = new HashMap<>(9); form.put("grant_type", "authorization_code"); form.put("code", authCallback.getCode()); @@ -140,7 +140,7 @@ private void checkResponse(JSONObject jsonObject) { * @return AuthUser */ @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String accessToken = authToken.getAccessToken(); this.checkToken(accessToken); diff --git a/src/main/java/me/zhyd/oauth/request/AuthAppleRequest.java b/src/main/java/me/zhyd/oauth/request/AuthAppleRequest.java index 20b41da6..9c1b17b2 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthAppleRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthAppleRequest.java @@ -50,7 +50,7 @@ public String authorize(String state) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { if (!StringUtils.isEmpty(authCallback.getError())) { throw new AuthException(authCallback.getError()); } @@ -76,7 +76,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { Base64.Decoder urlDecoder = Base64.getUrlDecoder(); String[] idToken = authToken.getIdToken().split("\\."); String payload = new String(urlDecoder.decode(idToken[1])); diff --git a/src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java b/src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java index 6f9851c8..c75c15b8 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java @@ -34,7 +34,7 @@ public AuthBaiduRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { String response = doPostAuthorizationCode(authCallback.getCode()); return getAuthToken(response); } @@ -48,7 +48,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { * @return AuthUser */ @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String userInfo = doGetUserInfo(authToken); JSONObject object = JSONObject.parseObject(userInfo); this.checkResponse(object); diff --git a/src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java b/src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java index 6adc72b5..6885ec83 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java @@ -30,7 +30,7 @@ public AuthCodingRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { String response = doGetAuthorizationCode(authCallback.getCode()); JSONObject accessTokenObject = JSONObject.parseObject(response); this.checkResponse(accessTokenObject); @@ -42,7 +42,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String response = doGetUserInfo(authToken); JSONObject object = JSONObject.parseObject(response); this.checkResponse(object); diff --git a/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java b/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java index 074a38d0..e6571319 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java @@ -28,7 +28,7 @@ public AuthCsdnRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { String response = doPostAuthorizationCode(authCallback.getCode()); JSONObject accessTokenObject = JSONObject.parseObject(response); this.checkResponse(accessTokenObject); @@ -36,7 +36,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String response = doGetUserInfo(authToken); JSONObject object = JSONObject.parseObject(response); this.checkResponse(object); diff --git a/src/main/java/me/zhyd/oauth/request/AuthDefaultRequest.java b/src/main/java/me/zhyd/oauth/request/AuthDefaultRequest.java index 10168aa7..02114064 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthDefaultRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthDefaultRequest.java @@ -43,25 +43,6 @@ public AuthDefaultRequest(AuthConfig config, AuthSource source, AuthStateCache a this.checkConfig(config); } - /** - * 获取access token - * - * @param authCallback 授权成功后的回调参数 - * @return token - * @see AuthDefaultRequest#authorize() - * @see AuthDefaultRequest#authorize(String) - */ - protected abstract AuthToken getAccessToken(AuthCallback authCallback); - - /** - * 使用token换取用户信息 - * - * @param authToken token信息 - * @return 用户信息 - * @see AuthDefaultRequest#getAccessToken(AuthCallback) - */ - protected abstract AuthUser getUserInfo(AuthToken authToken); - /** * 统一的登录入口。当通过{@link AuthDefaultRequest#authorize(String)}授权成功后,会跳转到调用方的相关回调方法中 * 方法的入参可以使用{@code AuthCallback},{@code AuthCallback}类中封装好了OAuth2授权回调所需要的参数 diff --git a/src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java b/src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java index df5accb5..0536f23a 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java @@ -34,12 +34,12 @@ public AuthDouyinRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { return this.getToken(accessTokenUrl(authCallback.getCode())); } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String response = doGetUserInfo(authToken); JSONObject userInfoObject = JSONObject.parseObject(response); this.checkResponse(userInfoObject); diff --git a/src/main/java/me/zhyd/oauth/request/AuthElemeRequest.java b/src/main/java/me/zhyd/oauth/request/AuthElemeRequest.java index 3c87fd9a..93f86432 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthElemeRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthElemeRequest.java @@ -44,7 +44,7 @@ public AuthElemeRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { Map form = new HashMap<>(7); form.put("client_id", config.getClientId()); form.put("redirect_uri", config.getRedirectUri()); @@ -66,7 +66,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { Map parameters = new HashMap<>(4); // 获取商户账号信息的API接口名称 String action = "eleme.user.getUser"; diff --git a/src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java b/src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java index 597acdbe..b50244ae 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java @@ -32,7 +32,7 @@ public AuthFacebookRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { String response = doPostAuthorizationCode(authCallback.getCode()); JSONObject accessTokenObject = JSONObject.parseObject(response); this.checkResponse(accessTokenObject); @@ -44,7 +44,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String userInfo = doGetUserInfo(authToken); JSONObject object = JSONObject.parseObject(userInfo); this.checkResponse(object); diff --git a/src/main/java/me/zhyd/oauth/request/AuthFeishuRequest.java b/src/main/java/me/zhyd/oauth/request/AuthFeishuRequest.java index 31b62837..f976a76f 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthFeishuRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthFeishuRequest.java @@ -66,7 +66,7 @@ private String getAppAccessToken() { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { JSONObject requestObject = new JSONObject(); requestObject.put("app_access_token", this.getAppAccessToken()); requestObject.put("grant_type", "authorization_code"); @@ -76,7 +76,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String accessToken = authToken.getAccessToken(); String response = new HttpUtils(config.getHttpConfig()).get(source.userInfo(), null, new HttpHeader() .add("Content-Type", "application/json") diff --git a/src/main/java/me/zhyd/oauth/request/AuthFigmaRequest.java b/src/main/java/me/zhyd/oauth/request/AuthFigmaRequest.java index c5f0efa2..4f874cc6 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthFigmaRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthFigmaRequest.java @@ -36,7 +36,7 @@ public String authorize(String state) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { HttpHeader header = new HttpHeader() .add("content-type", "application/x-www-form-urlencoded") .add("Authorization", "Basic " + Base64Utils.encode(config.getClientId().concat(":").concat(config.getClientSecret()))); @@ -86,7 +86,7 @@ protected String refreshTokenUrl(String refreshToken) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { HttpHeader header = new HttpHeader().add("Authorization", "Bearer " + authToken.getAccessToken()); String response = new HttpUtils(config.getHttpConfig()).get(super.userInfoUrl(authToken), null, header, false).getBody(); JSONObject dataObj = JSONObject.parseObject(response); diff --git a/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java b/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java index 735701c6..2755d044 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java @@ -30,7 +30,7 @@ public AuthGiteeRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { String response = doPostAuthorizationCode(authCallback.getCode()); JSONObject accessTokenObject = JSONObject.parseObject(response); this.checkResponse(accessTokenObject); @@ -44,7 +44,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String userInfo = doGetUserInfo(authToken); JSONObject object = JSONObject.parseObject(userInfo); this.checkResponse(object); diff --git a/src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java b/src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java index 20231628..360151a5 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java @@ -35,7 +35,7 @@ public AuthGithubRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { String response = doPostAuthorizationCode(authCallback.getCode()); Map res = GlobalAuthUtils.parseStringToMap(response); @@ -49,7 +49,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { HttpHeader header = new HttpHeader(); header.add("Authorization", "token " + authToken.getAccessToken()); String response = new HttpUtils(config.getHttpConfig()).get(UrlBuilder.fromBaseUrl(source.userInfo()).build(), null, header, false).getBody(); diff --git a/src/main/java/me/zhyd/oauth/request/AuthGitlabRequest.java b/src/main/java/me/zhyd/oauth/request/AuthGitlabRequest.java index a56a69d4..91455f7e 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthGitlabRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthGitlabRequest.java @@ -30,7 +30,7 @@ public AuthGitlabRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { String response = doPostAuthorizationCode(authCallback.getCode()); JSONObject object = JSONObject.parseObject(response); @@ -46,7 +46,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String response = doGetUserInfo(authToken); JSONObject object = JSONObject.parseObject(response); diff --git a/src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java b/src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java index 04d7493b..988e5d8e 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java @@ -33,7 +33,7 @@ public AuthGoogleRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { String response = doPostAuthorizationCode(authCallback.getCode()); JSONObject accessTokenObject = JSONObject.parseObject(response); this.checkResponse(accessTokenObject); @@ -47,7 +47,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { HttpHeader httpHeader = new HttpHeader(); httpHeader.add("Authorization", "Bearer " + authToken.getAccessToken()); String userInfo = new HttpUtils(config.getHttpConfig()).post(userInfoUrl(authToken), null, httpHeader).getBody(); diff --git a/src/main/java/me/zhyd/oauth/request/AuthHuaweiRequest.java b/src/main/java/me/zhyd/oauth/request/AuthHuaweiRequest.java index 7c414073..22a12d68 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthHuaweiRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthHuaweiRequest.java @@ -46,7 +46,7 @@ public AuthHuaweiRequest(AuthConfig config, AuthStateCache authStateCache) { * @see AuthDefaultRequest#authorize(String) */ @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { Map form = new HashMap<>(8); form.put("grant_type", "authorization_code"); form.put("code", authCallback.getAuthorization_code()); @@ -66,7 +66,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { * @see AuthDefaultRequest#getAccessToken(AuthCallback) */ @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { Map form = new HashMap<>(7); form.put("nsp_ts", System.currentTimeMillis() + ""); form.put("access_token", authToken.getAccessToken()); diff --git a/src/main/java/me/zhyd/oauth/request/AuthJdRequest.java b/src/main/java/me/zhyd/oauth/request/AuthJdRequest.java index 4769ea85..4159b9f0 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthJdRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthJdRequest.java @@ -39,7 +39,7 @@ public AuthJdRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { Map params = new HashMap<>(7); params.put("app_key", config.getClientId()); @@ -61,7 +61,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { UrlBuilder urlBuilder = UrlBuilder.fromBaseUrl(source.userInfo()) .queryParam("access_token", authToken.getAccessToken()) .queryParam("app_key", config.getClientId()) diff --git a/src/main/java/me/zhyd/oauth/request/AuthLineRequest.java b/src/main/java/me/zhyd/oauth/request/AuthLineRequest.java index 13d2fe30..722d201c 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthLineRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthLineRequest.java @@ -36,7 +36,7 @@ public AuthLineRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { Map params = new HashMap<>(); params.put("grant_type", "authorization_code"); params.put("code", authCallback.getCode()); @@ -56,7 +56,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String userInfo = new HttpUtils(config.getHttpConfig()).get(source.userInfo(), null, new HttpHeader() .add("Content-Type", "application/x-www-form-urlencoded") .add("Authorization", "Bearer ".concat(authToken.getAccessToken())), false).getBody(); diff --git a/src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java b/src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java index 40598c85..f59ad233 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java @@ -36,12 +36,12 @@ public AuthLinkedinRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { return this.getToken(accessTokenUrl(authCallback.getCode())); } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String accessToken = authToken.getAccessToken(); HttpHeader httpHeader = new HttpHeader(); httpHeader.add("Host", "api.linkedin.com"); diff --git a/src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java b/src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java index 5a12936e..b1c5b17d 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java @@ -34,7 +34,7 @@ public AuthMeituanRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { Map form = new HashMap<>(7); form.put("app_id", config.getClientId()); form.put("secret", config.getClientSecret()); @@ -54,7 +54,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { Map form = new HashMap<>(5); form.put("app_id", config.getClientId()); form.put("secret", config.getClientSecret()); diff --git a/src/main/java/me/zhyd/oauth/request/AuthMiRequest.java b/src/main/java/me/zhyd/oauth/request/AuthMiRequest.java index 380816ea..cba8a991 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthMiRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthMiRequest.java @@ -38,7 +38,7 @@ public AuthMiRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { return getToken(accessTokenUrl(authCallback.getCode())); } @@ -64,7 +64,7 @@ private AuthToken getToken(String accessTokenUrl) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { // 获取用户信息 String userResponse = doGetUserInfo(authToken); diff --git a/src/main/java/me/zhyd/oauth/request/AuthOktaRequest.java b/src/main/java/me/zhyd/oauth/request/AuthOktaRequest.java index 5fa7b452..150ed60e 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthOktaRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthOktaRequest.java @@ -40,7 +40,7 @@ public AuthOktaRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { String tokenUrl = accessTokenUrl(authCallback.getCode()); return getAuthToken(tokenUrl); } @@ -79,7 +79,7 @@ public AuthResponse refresh(AuthToken authToken) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { HttpHeader header = new HttpHeader() .add("Authorization", "Bearer " + authToken.getAccessToken()); String response = new HttpUtils(config.getHttpConfig()).post(userInfoUrl(authToken), null, header, false).getBody(); diff --git a/src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java b/src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java index af5eb4e0..32ed2a91 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java @@ -28,7 +28,7 @@ public AuthOschinaRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { String response = doPostAuthorizationCode(authCallback.getCode()); JSONObject accessTokenObject = JSONObject.parseObject(response); this.checkResponse(accessTokenObject); @@ -41,7 +41,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String response = doGetUserInfo(authToken); JSONObject object = JSONObject.parseObject(response); this.checkResponse(object); diff --git a/src/main/java/me/zhyd/oauth/request/AuthPinterestRequest.java b/src/main/java/me/zhyd/oauth/request/AuthPinterestRequest.java index 98958769..e6fff1a9 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthPinterestRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthPinterestRequest.java @@ -36,7 +36,7 @@ public AuthPinterestRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { String response = doPostAuthorizationCode(authCallback.getCode()); JSONObject accessTokenObject = JSONObject.parseObject(response); this.checkResponse(accessTokenObject); @@ -47,7 +47,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String userinfoUrl = userInfoUrl(authToken); // TODO: 是否需要 .setFollowRedirects(true) String response = new HttpUtils(config.getHttpConfig()).get(userinfoUrl).getBody(); diff --git a/src/main/java/me/zhyd/oauth/request/AuthProginnRequest.java b/src/main/java/me/zhyd/oauth/request/AuthProginnRequest.java index 03a56be8..9dc330be 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthProginnRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthProginnRequest.java @@ -34,7 +34,7 @@ public AuthProginnRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { Map params = new HashMap<>(); params.put("code", authCallback.getCode()); params.put("client_id", config.getClientId()); @@ -54,7 +54,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String userInfo = doGetUserInfo(authToken); JSONObject object = JSONObject.parseObject(userInfo); this.checkResponse(object); diff --git a/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java b/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java index c6db06dd..c278d6d8 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java @@ -33,7 +33,7 @@ public AuthQqRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { String response = doGetAuthorizationCode(authCallback.getCode()); return getAuthToken(response); } @@ -45,7 +45,7 @@ public AuthResponse refresh(AuthToken authToken) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String openId = this.getOpenId(authToken); String response = doGetUserInfo(authToken); JSONObject object = JSONObject.parseObject(response); diff --git a/src/main/java/me/zhyd/oauth/request/AuthRenrenRequest.java b/src/main/java/me/zhyd/oauth/request/AuthRenrenRequest.java index ada0e751..7e17e3a8 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthRenrenRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthRenrenRequest.java @@ -38,12 +38,12 @@ public AuthRenrenRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { return this.getToken(accessTokenUrl(authCallback.getCode())); } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String response = doGetUserInfo(authToken); JSONObject userObj = JSONObject.parseObject(response).getJSONObject("response"); diff --git a/src/main/java/me/zhyd/oauth/request/AuthRequest.java b/src/main/java/me/zhyd/oauth/request/AuthRequest.java index bbe49379..e849bbb2 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthRequest.java @@ -44,6 +44,25 @@ default String authorize(String state) { throw new AuthException(AuthResponseStatus.NOT_IMPLEMENTED); } + /** + * 获取access token + * + * @param authCallback 授权成功后的回调参数 + * @return token + * @see AuthDefaultRequest#authorize() + * @see AuthDefaultRequest#authorize(String) + */ + AuthToken getAccessToken(AuthCallback authCallback); + + /** + * 使用token换取用户信息 + * + * @param authToken token信息 + * @return 用户信息 + * @see AuthDefaultRequest#getAccessToken(AuthCallback) + */ + AuthUser getUserInfo(AuthToken authToken); + /** * 第三方登录 * diff --git a/src/main/java/me/zhyd/oauth/request/AuthSlackRequest.java b/src/main/java/me/zhyd/oauth/request/AuthSlackRequest.java index b1e1e30a..95c46491 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthSlackRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthSlackRequest.java @@ -35,7 +35,7 @@ public AuthSlackRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { HttpHeader header = new HttpHeader() .add("Content-Type", "application/x-www-form-urlencoded"); String response = new HttpUtils(config.getHttpConfig()) @@ -51,7 +51,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { HttpHeader header = new HttpHeader() .add("Content-Type", "application/x-www-form-urlencoded") .add("Authorization", "Bearer ".concat(authToken.getAccessToken())); diff --git a/src/main/java/me/zhyd/oauth/request/AuthStackOverflowRequest.java b/src/main/java/me/zhyd/oauth/request/AuthStackOverflowRequest.java index 969b4564..f35d89c7 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthStackOverflowRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthStackOverflowRequest.java @@ -37,7 +37,7 @@ public AuthStackOverflowRequest(AuthConfig config, AuthStateCache authStateCache } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { String accessTokenUrl = accessTokenUrl(authCallback.getCode()); Map form = MapUtil.parseStringToMap(accessTokenUrl, false); HttpHeader httpHeader = new HttpHeader(); @@ -54,7 +54,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String userInfoUrl = UrlBuilder.fromBaseUrl(this.source.userInfo()) .queryParam("access_token", authToken.getAccessToken()) .queryParam("site", "stackoverflow") diff --git a/src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java b/src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java index eea7b156..d37e3986 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java @@ -33,7 +33,7 @@ public AuthTaobaoRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { return AuthToken.builder().accessCode(authCallback.getCode()).build(); } @@ -58,7 +58,7 @@ private void checkResponse(JSONObject object) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String response = doPostAuthorizationCode(authToken.getAccessCode()); JSONObject accessTokenObject = JSONObject.parseObject(response); if (accessTokenObject.containsKey("error")) { diff --git a/src/main/java/me/zhyd/oauth/request/AuthTeambitionRequest.java b/src/main/java/me/zhyd/oauth/request/AuthTeambitionRequest.java index 308a178b..d39fdf51 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthTeambitionRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthTeambitionRequest.java @@ -38,7 +38,7 @@ public AuthTeambitionRequest(AuthConfig config, AuthStateCache authStateCache) { * @return 所有信息 */ @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { Map form = new HashMap<>(7); form.put("client_id", config.getClientId()); form.put("client_secret", config.getClientSecret()); @@ -57,7 +57,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String accessToken = authToken.getAccessToken(); HttpHeader httpHeader = new HttpHeader(); diff --git a/src/main/java/me/zhyd/oauth/request/AuthToutiaoRequest.java b/src/main/java/me/zhyd/oauth/request/AuthToutiaoRequest.java index ef6a84b8..f361e317 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthToutiaoRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthToutiaoRequest.java @@ -29,7 +29,7 @@ public AuthToutiaoRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { String response = doGetAuthorizationCode(authCallback.getCode()); JSONObject accessTokenObject = JSONObject.parseObject(response); @@ -43,7 +43,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String userResponse = doGetUserInfo(authToken); JSONObject userProfile = JSONObject.parseObject(userResponse); diff --git a/src/main/java/me/zhyd/oauth/request/AuthTwitterRequest.java b/src/main/java/me/zhyd/oauth/request/AuthTwitterRequest.java index b4c0d669..9f1bb300 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthTwitterRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthTwitterRequest.java @@ -88,7 +88,7 @@ public AuthToken getRequestToken() { * @return access token */ @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { Map oauthParams = buildOauthParams(); oauthParams.put("oauth_token", authCallback.getOauth_token()); oauthParams.put("oauth_verifier", authCallback.getOauth_verifier()); @@ -115,7 +115,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { Map queryParams = new HashMap<>(5); queryParams.put("include_entities", Boolean.toString(true)); queryParams.put("include_email", Boolean.toString(true)); diff --git a/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseThirdQrcodeRequest.java b/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseThirdQrcodeRequest.java index 79d0e180..6b1c25a2 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseThirdQrcodeRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseThirdQrcodeRequest.java @@ -56,7 +56,7 @@ public AuthResponse login(AuthCallback authCallback) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { try { String response = doGetAuthorizationCode(accessTokenUrl()); JSONObject object = this.checkResponse(response); @@ -89,7 +89,7 @@ protected String accessTokenUrl() { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { JSONObject response = this.checkResponse(doGetUserInfo(authToken)); return AuthUser.builder() .rawUserInfo(response) diff --git a/src/main/java/me/zhyd/oauth/request/AuthWeChatMpRequest.java b/src/main/java/me/zhyd/oauth/request/AuthWeChatMpRequest.java index 0502f284..be139cce 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthWeChatMpRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthWeChatMpRequest.java @@ -36,12 +36,12 @@ public AuthWeChatMpRequest(AuthConfig config, AuthStateCache authStateCache) { * @return 所有信息 */ @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { return this.getToken(accessTokenUrl(authCallback.getCode())); } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String openId = authToken.getOpenId(); String scope = authToken.getScope(); diff --git a/src/main/java/me/zhyd/oauth/request/AuthWeChatOpenRequest.java b/src/main/java/me/zhyd/oauth/request/AuthWeChatOpenRequest.java index 44f724f7..08cfc557 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthWeChatOpenRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthWeChatOpenRequest.java @@ -36,12 +36,12 @@ public AuthWeChatOpenRequest(AuthConfig config, AuthStateCache authStateCache) { * @return 所有信息 */ @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { return this.getToken(accessTokenUrl(authCallback.getCode())); } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String openId = authToken.getOpenId(); String response = doGetUserInfo(authToken); diff --git a/src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java b/src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java index 5f6024aa..509e1aac 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java @@ -33,7 +33,7 @@ public AuthWeiboRequest(AuthConfig config, AuthStateCache authStateCache) { } @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { String response = doPostAuthorizationCode(authCallback.getCode()); JSONObject accessTokenObject = JSONObject.parseObject(response); if (accessTokenObject.containsKey("error")) { @@ -48,7 +48,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { } @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { String accessToken = authToken.getAccessToken(); String uid = authToken.getUid(); String oauthParam = String.format("uid=%s&access_token=%s", uid, accessToken); diff --git a/src/main/java/me/zhyd/oauth/request/AuthXmlyRequest.java b/src/main/java/me/zhyd/oauth/request/AuthXmlyRequest.java index 2430aa21..93c89c5c 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthXmlyRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthXmlyRequest.java @@ -42,7 +42,7 @@ public AuthXmlyRequest(AuthConfig config, AuthStateCache authStateCache) { * @see AuthDefaultRequest#authorize(String) */ @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { Map map = new HashMap<>(9); map.put("code", authCallback.getCode()); map.put("client_id", config.getClientId()); diff --git a/src/test/java/me/zhyd/oauth/request/AuthExtendRequest.java b/src/test/java/me/zhyd/oauth/request/AuthExtendRequest.java index 6030f2cc..6bccad72 100644 --- a/src/test/java/me/zhyd/oauth/request/AuthExtendRequest.java +++ b/src/test/java/me/zhyd/oauth/request/AuthExtendRequest.java @@ -36,7 +36,7 @@ public AuthExtendRequest(AuthConfig config, AuthStateCache authStateCache) { * @see AuthDefaultRequest#authorize(String) */ @Override - protected AuthToken getAccessToken(AuthCallback authCallback) { + public AuthToken getAccessToken(AuthCallback authCallback) { return AuthToken.builder() .openId("openId") .expireIn(1000) @@ -56,7 +56,7 @@ protected AuthToken getAccessToken(AuthCallback authCallback) { * @see AuthDefaultRequest#getAccessToken(AuthCallback) */ @Override - protected AuthUser getUserInfo(AuthToken authToken) { + public AuthUser getUserInfo(AuthToken authToken) { return AuthUser.builder() .username("test") .nickname("test")