diff --git a/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseWebRequest.java b/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseWebRequest.java index 3a9747fc4725aaa8cbf6f1c53a8983da5f8e0e85..5d517928529d55bfcf486693d38d5f15bcd16d7c 100644 --- a/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseWebRequest.java +++ b/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseWebRequest.java @@ -5,6 +5,7 @@ import me.zhyd.oauth.config.AuthConfig; import me.zhyd.oauth.config.AuthDefaultSource; import me.zhyd.oauth.enums.scope.AuthWeChatEnterpriseWebScope; import me.zhyd.oauth.utils.AuthScopeUtils; +import me.zhyd.oauth.utils.GlobalAuthUtils; import me.zhyd.oauth.utils.UrlBuilder; /** @@ -28,7 +29,7 @@ public class AuthWeChatEnterpriseWebRequest extends AbstractAuthWeChatEnterprise public String authorize(String state) { return UrlBuilder.fromBaseUrl(source.authorize()) .queryParam("appid", config.getClientId()) - .queryParam("redirect_uri", config.getRedirectUri()) + .queryParam("redirect_uri", GlobalAuthUtils.urlEncode(config.getRedirectUri())) .queryParam("response_type", "code") .queryParam("scope", this.getScopes(",", false, AuthScopeUtils.getDefaultScopes(AuthWeChatEnterpriseWebScope.values()))) .queryParam("state", getRealState(state).concat("#wechat_redirect")) diff --git a/src/test/java/me/zhyd/oauth/request/AuthWeChatEnterpriseWebRequestTest.java b/src/test/java/me/zhyd/oauth/request/AuthWeChatEnterpriseWebRequestTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b0d1c9318acdb24af5c511f75c0c612fc9c92b92 --- /dev/null +++ b/src/test/java/me/zhyd/oauth/request/AuthWeChatEnterpriseWebRequestTest.java @@ -0,0 +1,20 @@ +package me.zhyd.oauth.request; + +import me.zhyd.oauth.config.AuthConfig; +import me.zhyd.oauth.utils.AuthStateUtils; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class AuthWeChatEnterpriseWebRequestTest { + + @Test + public void authorize() { + AuthRequest request = new AuthWeChatEnterpriseWebRequest(AuthConfig.builder() + .clientId("a") + .clientSecret("a") + .redirectUri("https://www.justauth.cn") + .build()); + System.out.println(request.authorize(AuthStateUtils.createState())); + } +}