Skip to content

Commit

Permalink
[merge] requestDto에 RedirectUri 담도록 구현
Browse files Browse the repository at this point in the history
[feat] requestDto에 RedirectUri 담도록 구현
  • Loading branch information
bo-ram-bo-ram authored Aug 11, 2024
2 parents 0500bac + 96308b8 commit 4a8eca7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

import com.pickple.server.api.user.domain.SocialType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.NotBlank;

public record UserLoginRequest(
@NotNull(message = "소셜 로그인 종류가 입력되지 않았습니다.")
@NotBlank(message = "소셜 로그인 종류가 입력되지 않았습니다.")
@Schema(description = "소셜로그인 타입", example = "KAKAO")
SocialType socialType
SocialType socialType,

@NotBlank
@Schema(description = "리다이텍트 uri 값", example = "https://pick-ple.com/kakao/redirection or http://localhost:5173/kakao/redirection")
String redirectUri
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@
public class KakaoSocialService implements SocialService {

private static final String AUTH_CODE = "authorization_code";
private static final String REDIRECT_URI = "http://localhost:5173/kakao/redirection";

@Value("${kakao.clientId}")
private String clientId;
private final KakaoApiClient kakaoApiClient;
private final KakaoAuthApiClient kakaoAuthApiClient;


@Transactional
@Override
public UserInfoResponse login(
Expand All @@ -38,7 +36,7 @@ public UserInfoResponse login(
String accessToken;
try {
// 인가 코드로 Access Token + Refresh Token 받아오기
accessToken = getOAuth2Authentication(authorizationCode);
accessToken = getOAuth2Authentication(authorizationCode, loginRequest.redirectUri());
} catch (FeignException e) {
throw new CustomException(ErrorCode.AUTHENTICATION_CODE_EXPIRED);
}
Expand All @@ -47,12 +45,13 @@ public UserInfoResponse login(
}

private String getOAuth2Authentication(
final String authorizationCode
final String authorizationCode,
final String redirectUri
) {
KakaoAccessTokenResponse response = kakaoAuthApiClient.getOAuth2AccessToken(
AUTH_CODE,
clientId,
REDIRECT_URI,
redirectUri,
authorizationCode
);
return response.accessToken();
Expand Down

0 comments on commit 4a8eca7

Please sign in to comment.