Skip to content

Commit

Permalink
merge: 이슈해결 - #87
Browse files Browse the repository at this point in the history
[fix] 이슈해결 - #87
  • Loading branch information
sjk4618 authored Jan 20, 2025
2 parents fcb751f + 80f3d5a commit cc0f45f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.httpBasic(AbstractHttpConfigurer::disable)
.sessionManagement(
session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.authorizeHttpRequests( auth -> auth.anyRequest().permitAll()) //todo: 추후 변경
.authorizeHttpRequests( auth -> auth.anyRequest().permitAll())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.cakey.common.response.BaseResponse;
import com.fasterxml.jackson.databind.JsonMappingException;
import jakarta.persistence.EntityNotFoundException;
import lombok.val;
import org.hibernate.exception.ConstraintViolationException;
import org.springframework.context.MessageSourceResolvable;
import org.springframework.context.support.DefaultMessageSourceResolvable;
Expand All @@ -21,6 +22,7 @@
import org.springframework.web.servlet.NoHandlerFoundException;
import org.springframework.web.servlet.resource.NoResourceFoundException;

import java.lang.reflect.InvocationTargetException;
import java.util.stream.Collectors;

@RestControllerAdvice
Expand Down Expand Up @@ -166,6 +168,14 @@ public ResponseEntity<BaseResponse<?>> handleDataIntegrityViolationException(fin
}
}


@ExceptionHandler(InvocationTargetException.class)
public ResponseEntity<BaseResponse<?>> handleInvocationTargetException(final InvocationTargetException e) {
Throwable cause = e.getCause();
System.out.println(cause.getMessage());
return ApiResponseUtil.failure(ErrorBaseCode.INTERNAL_SERVER_ERROR, cause.getMessage());
}

/**
* 500 - 모든 예외 처리
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@FeignClient(name = "kakaoAuthApiClient", url = "https://kauth.kakao.com")
public interface KakaoAuthApiClient {

@PostMapping(value = "/oauth/token", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
@PostMapping(value = "/oauth/token")
KakaoAccessTokenRes getOAuth2AccessToken(
@RequestParam("grant_type") String grantType,
@RequestParam("client_id") String clientId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ public KakaoUserDto getKakaoUserInfo(final String authorizationCode) {
}

String contentType = MediaType.APPLICATION_FORM_URLENCODED.toString();

// Access Token으로 유저 정보 불러오기
final KakaoUserDto kakaoUserDto = getUserInfo(kakaoAccessToken, contentType);
return kakaoUserDto;
return getUserInfo(kakaoAccessToken, contentType);
}

private String getOAuth2Authentication(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.cakey.client.kakao.api.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public record KakaoAccessTokenRes(
String accessToken
) {
public static KakaoAccessTokenRes of(final String accessToken) {
return new KakaoAccessTokenRes(accessToken);
}
@JsonProperty("token_type") String tokenType,
@JsonProperty("access_token") String accessToken,
@JsonProperty("expires_in") Integer expiresIn,
@JsonProperty("refresh_token") String refreshToken,
@JsonProperty("refresh_token_expires_in") Integer refreshTokenExpiresIn,
@JsonProperty("scope") String scope) {
}

0 comments on commit cc0f45f

Please sign in to comment.