2024-08-31T15:23:38.935+09:00 INFO 19976 --- [common] [ main] c.l.feign.KakaoClientIntegrationTest : Started KakaoClientIntegrationTest in 6.552 seconds (process running for 9.803) OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended com.library.ApiException at com.library.feign.KakaoErrorDecoder.decode(KakaoErrorDecoder.java:29)
디버깅 수행
HTTP/1.1 401 Unauthorized
access-control-allow-headers: Authorization, KA, Origin, X-Requested-With, Content-Type, Accept
access-control-allow-methods: GET, OPTIONS
access-control-allow-origin: *
connection: keep-alive
content-type: application/json;charset=UTF-8
date: Sat, 31 Aug 2024 06:39:32 GMT
401
Kakao 도서 API에서 header값을 넣어줄 때 문제가 생긴듯 하다..
body 부분을 확인하자.
{"errorType":"AccessDeniedError","message":"cannot find Authorization : KakaoAK header"}
header가 잘못들어가 있었다.!
public class KakaoClientConfiguration {
@Bean
public RequestInterceptor requestInterceptor(@Value("${external.kakao.headers.rest-api-key}") String restApiKey) {
return requestTemplate -> requestTemplate.header("Authorization", "KakaoAK " + restApiKey);
}
@Bean
public KakaoErrorDecoder kakaoErrorDecoder(ObjectMapper objectMapper) {
return new KakaoErrorDecoder(objectMapper);
}
}
- 이렇게 config 설정을 통해 "KakaoAK "을 자동으로 넣어주는데
- rest-api-key를 넣어줄 때 KakaoAK efksdfksfklsjfdklsfjkl 이렇게 넣어버린 셈..
원인은
테스트 코드 실행 시 올바르지 않은 header값을 넣었기 때문
AccessDeniedError
'Spring관련 기술 > 서버개발' 카테고리의 다른 글
MQ pubsub 간단 정리 (1) | 2024.09.29 |
---|---|
개발환경에서 테스트 데이터 넣기 (0) | 2024.08.31 |
MethodArgumentTypeMismatchException (0) | 2024.08.30 |
MissingServletRequestParameterException (0) | 2024.08.30 |
NoResourceFoundException (0) | 2024.08.30 |