1
0
mirror of synced 2026-02-07 11:07:47 +08:00
Files
JustAuth/src/test/java/me/zhyd/oauth/AuthRequestTest.java
yadong.zhang ebccbb2d2f 👽 更新文档
2019-02-18 13:42:00 +08:00

66 lines
2.2 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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 org.junit.Test;
import javax.servlet.http.HttpServletResponse;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2019/2/18 13:10
* @since 1.8
*/
public class AuthRequestTest {
@Test
public void giteeTest(HttpServletResponse response) {
AuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder()
.clientId("clientId")
.clientSecret("clientSecret")
.redirectUri("redirectUri")
.build());
// 自动跳转到授权页面
authRequest.authorize(response);
// 返回授权页面,可自行调整
authRequest.authorize();
// 授权登陆后会返回一个code用这个code进行登录
authRequest.login("code");
}
@Test
public void githubTest(HttpServletResponse response) {
AuthRequest authRequest = new AuthGithubRequest(AuthConfig.builder()
.clientId("clientId")
.clientSecret("clientSecret")
.redirectUri("redirectUri")
.build());
// 自动跳转到授权页面
authRequest.authorize(response);
// 返回授权页面,可自行调整
authRequest.authorize();
// 授权登陆后会返回一个code用这个code进行登录
authRequest.login("code");
}
@Test
public void weiboTest(HttpServletResponse response) {
AuthRequest authRequest = new AuthWeiboRequest(AuthConfig.builder()
.clientId("clientId")
.clientSecret("clientSecret")
.redirectUri("redirectUri")
.build());
// 自动跳转到授权页面
authRequest.authorize(response);
// 返回授权页面,可自行调整
authRequest.authorize();
// 授权登陆后会返回一个code用这个code进行登录
authRequest.login("code");
}
}