Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

public interface OAuth2UseCase {

UserKakaoLoginResponse kakaoLogin(String code);
UserKakaoLoginResponse kakaoLogin(String code, String redirectUri);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class OAuth2UseCaseImpl implements OAuth2UseCase {

@Transactional
@Override
public UserKakaoLoginResponse kakaoLogin(String code) {
KakaoTokenResponse kakaoToken = kakaoGetService.getTokenFromKakao(code);
public UserKakaoLoginResponse kakaoLogin(String code, String redirectUri) {
KakaoTokenResponse kakaoToken = kakaoGetService.getTokenFromKakao(code, redirectUri);
KakaoUserInfoResponse kakaoUserInfo = kakaoGetService.getUserInfo(kakaoToken.accessToken());

User user = userSaveService.save(kakaoUserInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import leets.bookmark.global.auth.oauth2.application.exception.KakaoAuthorizationCodeInvalidException;
import leets.bookmark.global.auth.oauth2.application.exception.KakaoServerException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatusCode;
import org.springframework.stereotype.Service;
Expand All @@ -15,15 +14,12 @@

import static org.springframework.http.HttpHeaders.*;

@Slf4j
@Service
@RequiredArgsConstructor
public class KakaoGetService {

@Value("${spring.security.oauth2.client.registration.kakao.client-id}")
private String clientId;
@Value("${spring.security.oauth2.client.registration.kakao.redirect-uri}")
private String redirectUri;
@Value("${spring.security.oauth2.client.provider.kakao.token-uri}")
private String tokenUri;
@Value("${spring.security.oauth2.client.provider.kakao.user-info-uri}")
Expand All @@ -32,7 +28,7 @@ public class KakaoGetService {
public static final String BEARER = "Bearer ";
public static final String APPLICATION_X_WWW_FORM_URLENCODED_CHARSET_UTF_8 = "application/x-www-form-urlencoded;charset=utf-8";

public KakaoTokenResponse getTokenFromKakao(String code) {
public KakaoTokenResponse getTokenFromKakao(String code, String redirectUri) {
return WebClient.create(tokenUri).post()
.uri(uriBuilder -> uriBuilder
.queryParam("grant_type", "authorization_code")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public CommonResponse<JwtTokenDto> reissue(@Validated @RequestBody JwtTokenReiss
}

@GetMapping("/login/kakao")
public CommonResponse<UserKakaoLoginResponse> kakaoLogin(@RequestParam("code") String code) {
UserKakaoLoginResponse response = oAuth2UseCase.kakaoLogin(code);
public CommonResponse<UserKakaoLoginResponse> kakaoLogin(@RequestParam("code") String code, @RequestParam("redirectUri") String redirectUri) {
UserKakaoLoginResponse response = oAuth2UseCase.kakaoLogin(code, redirectUri);
return CommonResponse.createSuccess(KAKAO_LOGIN_SUCCESS.getMessage(), response);
}
}