Skip to content

Commit

Permalink
🐛 oauth2 리다이렉션 설정
Browse files Browse the repository at this point in the history
- 401 에러를 수정하고 있습니다.
  • Loading branch information
Ganghee-Lee-0522 committed Jan 12, 2024
1 parent 2fe2959 commit 26f80f1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,28 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
}

// Auth 컨트롤러로 리다이렉트
String redirectUrl = UriComponentsBuilder.fromUriString("/api/auth/redirect")
.queryParam("accessToken", token.getAccessToken())
.queryParam("refreshToken", token.getRefreshToken())
.toUriString();
getRedirectStrategy().sendRedirect(request, response, redirectUrl);
// 를 하지마
// String redirectUrl = UriComponentsBuilder.fromUriString("/api/auth/redirect")
// .queryParam("accessToken", token.getAccessToken())
// .queryParam("refreshToken", token.getRefreshToken())
// .toUriString();


// getRedirectStrategy().sendRedirect(request, response, redirectUrl);


String redirectUrl = "https://kidari.site/redirect";

log.info("redirectUrl -> {}", redirectUrl);
log.info("accessToken -> {}", token.getAccessToken());
log.info("refreshToken -> {}", token.getRefreshToken());

response = authService.login(response, token.getAccessToken(), token.getRefreshToken());

// 별다른 대조 없이, 기등록된 닉네임이면 로그인 성공
response.sendRedirect(redirectUrl);

log.info("response -> {}", response.getHeader("Set-Cookie"));
log.info("response -> {}", response.getHeaderNames());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ public class AuthController {

private final AuthService authService;

@GetMapping("/api/auth/redirect") // 인증 성공 시 리다이렉트 경로
public void login(HttpServletRequest request, HttpServletResponse response,
@RequestParam("accessToken") String accessToken,
@RequestParam("refreshToken") String refreshToken) throws IOException {

log.info("redirect to /auth/redirect");

String redirectUrl = "https://kidari.site/redirect";

log.info("AuthController의 login");
log.info("accessToken -> {}", accessToken);
log.info("refreshToken -> {}", refreshToken);

HttpServletResponse response1 = authService.login(response, accessToken, refreshToken);

// 별다른 대조 없이, 기등록된 닉네임이면 로그인 성공
response1.sendRedirect(redirectUrl);

log.info("response -> {}", response1.getHeader("Set-Cookie"));
log.info("response -> {}", response1.getHeaderNames());

}
// @GetMapping("/api/auth/redirect") // 인증 성공 시 리다이렉트 경로
// public void login(HttpServletRequest request, HttpServletResponse response,
// @RequestParam("accessToken") String accessToken,
// @RequestParam("refreshToken") String refreshToken) throws IOException {
//
// log.info("redirect to /auth/redirect");
//
// String redirectUrl = "https://kidari.site/redirect";
//
// log.info("AuthController의 login");
// log.info("accessToken -> {}", accessToken);
// log.info("refreshToken -> {}", refreshToken);
//
// HttpServletResponse response1 = authService.login(response, accessToken, refreshToken);
//
// // 별다른 대조 없이, 기등록된 닉네임이면 로그인 성공
// response1.sendRedirect(redirectUrl);
//
// log.info("response -> {}", response1.getHeader("Set-Cookie"));
// log.info("response -> {}", response1.getHeaderNames());
//
// }

}

0 comments on commit 26f80f1

Please sign in to comment.