✨ 支持钉钉登录
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
package me.zhyd.oauth;
|
||||
|
||||
import me.zhyd.oauth.config.AuthConfig;
|
||||
import me.zhyd.oauth.request.AuthGiteeRequest;
|
||||
import me.zhyd.oauth.request.AuthGithubRequest;
|
||||
import me.zhyd.oauth.request.AuthRequest;
|
||||
import me.zhyd.oauth.request.AuthWeiboRequest;
|
||||
import me.zhyd.oauth.request.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -19,7 +16,8 @@ import javax.servlet.http.HttpServletResponse;
|
||||
public class AuthRequestTest {
|
||||
|
||||
@Test
|
||||
public void giteeTest(HttpServletResponse response) {
|
||||
public void giteeTest() {
|
||||
HttpServletResponse response = null;
|
||||
AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder()
|
||||
.clientId("clientId")
|
||||
.clientSecret("clientSecret")
|
||||
@@ -29,12 +27,13 @@ public class AuthRequestTest {
|
||||
authRequest.authorize(response);
|
||||
// 返回授权页面,可自行调整
|
||||
authRequest.authorize();
|
||||
// 授权登陆后会返回一个code,用这个code进行登录
|
||||
// 授权登录后会返回一个code,用这个code进行登录
|
||||
authRequest.login("code");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void githubTest(HttpServletResponse response) {
|
||||
public void githubTest() {
|
||||
HttpServletResponse response = null;
|
||||
AuthRequest authRequest = new AuthGithubRequest(AuthConfig.builder()
|
||||
.clientId("clientId")
|
||||
.clientSecret("clientSecret")
|
||||
@@ -44,12 +43,13 @@ public class AuthRequestTest {
|
||||
authRequest.authorize(response);
|
||||
// 返回授权页面,可自行调整
|
||||
authRequest.authorize();
|
||||
// 授权登陆后会返回一个code,用这个code进行登录
|
||||
// 授权登录后会返回一个code,用这个code进行登录
|
||||
authRequest.login("code");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void weiboTest(HttpServletResponse response) {
|
||||
public void weiboTest() {
|
||||
HttpServletResponse response = null;
|
||||
AuthRequest authRequest = new AuthWeiboRequest(AuthConfig.builder()
|
||||
.clientId("clientId")
|
||||
.clientSecret("clientSecret")
|
||||
@@ -59,7 +59,24 @@ public class AuthRequestTest {
|
||||
authRequest.authorize(response);
|
||||
// 返回授权页面,可自行调整
|
||||
authRequest.authorize();
|
||||
// 授权登陆后会返回一个code,用这个code进行登录
|
||||
// 授权登录后会返回一个code,用这个code进行登录
|
||||
authRequest.login("code");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dingdingTest() {
|
||||
HttpServletResponse response = null;
|
||||
AuthRequest authRequest = new AuthDingTalkRequest(AuthConfig.builder()
|
||||
.clientId("dingoa2q6o3fomfk6vdqzy")
|
||||
.clientSecret("d5w75-R-yNtQsq_Ya_r50gOsKOy9WlmrlUOJkUJXKvsQp7NDPRHsj0epJriiN3yO")
|
||||
.redirectUri("http://61.149.7.121:8443/oauth/dingtalk/callback")
|
||||
.build());
|
||||
// 自动跳转到授权页面
|
||||
// authRequest.authorize(response);
|
||||
// 返回授权页面,可自行调整
|
||||
String url = authRequest.authorize();
|
||||
System.out.println(url);
|
||||
// 授权登录后会返回一个code,用这个code进行登录
|
||||
// authRequest.login("code");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user