mirror of
https://gitee.com/yadong.zhang/JustAuth.git
synced 2025-12-06 08:48:27 +08:00
💩 改进部分代码结构
This commit is contained in:
parent
72bb1d826f
commit
45e1195974
@ -103,13 +103,9 @@ public class AuthBaiduRequest extends AuthDefaultRequest {
|
||||
*/
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
return UrlBuilder.fromBaseUrl(source.authorize())
|
||||
.queryParam("response_type", "code")
|
||||
.queryParam("client_id", config.getClientId())
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
return UrlBuilder.fromBaseUrl(super.authorize(state))
|
||||
.queryParam("display", "popup")
|
||||
.queryParam("scope", this.getScopes(" ", true, AuthBaiduScope.getDefaultScopes()))
|
||||
.queryParam("state", getRealState(state))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@ -105,8 +105,7 @@ public class AuthFacebookRequest extends AuthDefaultRequest {
|
||||
*/
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
String authorizeUrl = super.authorize(state);
|
||||
return UrlBuilder.fromBaseUrl(authorizeUrl)
|
||||
return UrlBuilder.fromBaseUrl(super.authorize(state))
|
||||
.queryParam("scope", this.getScopes(",", false, AuthFacebookScope.getDefaultScopes()))
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -83,8 +83,7 @@ public class AuthGiteeRequest extends AuthDefaultRequest {
|
||||
*/
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
String authorizeUrl = super.authorize(state);
|
||||
return UrlBuilder.fromBaseUrl(authorizeUrl)
|
||||
return UrlBuilder.fromBaseUrl(super.authorize(state))
|
||||
.queryParam("scope", this.getScopes(" ", true, AuthGiteeScope.getDefaultScopes()))
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -83,8 +83,7 @@ public class AuthGithubRequest extends AuthDefaultRequest {
|
||||
*/
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
String authorizeUrl = super.authorize(state);
|
||||
return UrlBuilder.fromBaseUrl(authorizeUrl)
|
||||
return UrlBuilder.fromBaseUrl(super.authorize(state))
|
||||
.queryParam("scope", this.getScopes(" ", true, AuthGithubScope.getDefaultScopes()))
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -74,12 +74,9 @@ public class AuthGoogleRequest extends AuthDefaultRequest {
|
||||
*/
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
return UrlBuilder.fromBaseUrl(source.authorize())
|
||||
.queryParam("response_type", "code")
|
||||
.queryParam("client_id", config.getClientId())
|
||||
return UrlBuilder.fromBaseUrl(super.authorize(state))
|
||||
.queryParam("access_type", "offline")
|
||||
.queryParam("scope", this.getScopes(" ", false, AuthGoogleScope.getDefaultScopes()))
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
.queryParam("state", getRealState(state))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@ -130,30 +130,9 @@ public class AuthHuaweiRequest extends AuthDefaultRequest {
|
||||
*/
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
return UrlBuilder.fromBaseUrl(source.authorize())
|
||||
.queryParam("response_type", "code")
|
||||
.queryParam("client_id", config.getClientId())
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
return UrlBuilder.fromBaseUrl(super.authorize(state))
|
||||
.queryParam("access_type", "offline")
|
||||
.queryParam("scope", this.getScopes(" ", true, AuthHuaweiScope.getDefaultScopes()))
|
||||
.queryParam("state", getRealState(state))
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回获取accessToken的url
|
||||
*
|
||||
* @param code 授权码
|
||||
* @return 返回获取accessToken的url
|
||||
*/
|
||||
@Override
|
||||
protected String accessTokenUrl(String code) {
|
||||
return UrlBuilder.fromBaseUrl(source.accessToken())
|
||||
.queryParam("grant_type", "authorization_code")
|
||||
.queryParam("code", code)
|
||||
.queryParam("client_id", config.getClientId())
|
||||
.queryParam("client_secret", config.getClientSecret())
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@ -40,8 +40,7 @@ public class AuthKujialeRequest extends AuthDefaultRequest {
|
||||
*/
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
String authorizeUrl = super.authorize(state);
|
||||
return UrlBuilder.fromBaseUrl(authorizeUrl)
|
||||
return UrlBuilder.fromBaseUrl(super.authorize(state))
|
||||
.queryParam("scope", this.getScopes(",", false, AuthKujialeScope.getDefaultScopes()))
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -198,12 +198,8 @@ public class AuthLinkedinRequest extends AuthDefaultRequest {
|
||||
*/
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
return UrlBuilder.fromBaseUrl(source.authorize())
|
||||
.queryParam("response_type", "code")
|
||||
.queryParam("client_id", config.getClientId())
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
return UrlBuilder.fromBaseUrl(super.authorize(state))
|
||||
.queryParam("scope", this.getScopes(" ", false, AuthLinkedinScope.getDefaultScopes()))
|
||||
.queryParam("state", getRealState(state))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package me.zhyd.oauth.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.config.AuthDefaultSource;
|
||||
@ -12,6 +11,7 @@ import me.zhyd.oauth.model.AuthCallback;
|
||||
import me.zhyd.oauth.model.AuthResponse;
|
||||
import me.zhyd.oauth.model.AuthToken;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.utils.HttpUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -108,11 +108,7 @@ public class AuthMeituanRequest extends AuthDefaultRequest {
|
||||
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
return UrlBuilder.fromBaseUrl(source.authorize())
|
||||
.queryParam("response_type", "code")
|
||||
.queryParam("app_id", config.getClientId())
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
.queryParam("state", getRealState(state))
|
||||
return UrlBuilder.fromBaseUrl(super.authorize(state))
|
||||
.queryParam("scope", "")
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -125,13 +125,9 @@ public class AuthMiRequest extends AuthDefaultRequest {
|
||||
*/
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
return UrlBuilder.fromBaseUrl(source.authorize())
|
||||
.queryParam("response_type", "code")
|
||||
.queryParam("client_id", config.getClientId())
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
.queryParam("scope", this.getScopes(" ", true, AuthMiScope.getDefaultScopes()))
|
||||
return UrlBuilder.fromBaseUrl(super.authorize(state))
|
||||
.queryParam("skip_confirm", "false")
|
||||
.queryParam("state", getRealState(state))
|
||||
.queryParam("scope", this.getScopes(" ", true, AuthMiScope.getDefaultScopes()))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@ -123,13 +123,9 @@ public class AuthMicrosoftRequest extends AuthDefaultRequest {
|
||||
*/
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
return UrlBuilder.fromBaseUrl(source.authorize())
|
||||
.queryParam("response_type", "code")
|
||||
.queryParam("client_id", config.getClientId())
|
||||
.queryParam("redirect_uri", config.getRedirectUri())
|
||||
return UrlBuilder.fromBaseUrl(super.authorize(state))
|
||||
.queryParam("response_mode", "query")
|
||||
.queryParam("scope", this.getScopes(" ", true, AuthMicrosoftScope.getDefaultScopes()))
|
||||
.queryParam("state", getRealState(state))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user