토큰을 이용하여 사용자 정보 가져오기 문의

문의 시, 사용하시는 개발환경과 디벨로퍼스 앱ID를 알려주세요.


개발환경: 스프링 부트 3.1.4
앱ID: 853322

프론트 서버는 따로 구현하지 않고 백엔드를 통해서 요청 정보를 구현하고 있습니다.
스프링부트로 rest api를 통해 인가 코드와 access_token을 발급하는데 까지는 성공하였습니다. 하지만 해당 토큰을 가지고 사용자 정보를 가져오기 위해서 /v2/user/me 를 호출시 사용자 정보가 불러와 지지 않습니다.

    public ResponseEntity<String> getUserInfo(String token) throws Exception {
        String host = "https://kauth.kakao.com/v2/user/me";

        try {
            HttpHeaders headers2 = new org.springframework.http.HttpHeaders();
            headers2.add("Content-type", "application/x-www-form-urlencoded;charset=utf-8");
            headers2.add("Authorization","Bearer "+token);
            RestTemplate rt = new RestTemplate();
            MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
            HttpEntity<MultiValueMap<String, String>> httpEntity = new HttpEntity<>(params,headers2);
            ResponseEntity<String> response = rt.exchange(
                    host,
                    HttpMethod.GET,
                    httpEntity,
                    String.class
            );

            System.out.println("response = " + response);

            return response;
        }catch (Exception e){
            System.out.println("e = " + e);
            e.printStackTrace();
        }
        return null;
    }

HttpMethod.GET으로 호출 후 response를 출력해보면 다음과 같이 user 정보를 받아오는게 아닌 html 파일 형식으로 출력됩니다.

response = <200 OK OK,<!doctype html>
<html lang="ko">
 <head>
  <meta charset="utf-8">
  <meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width">
  <meta name="next-head-count" content="2">
  <meta http-equiv="x-ua-compatible" content="IE=edge">
  <meta content="website" property="og:type">
  <meta content="ì¹´ì¹´ì˜¤ê³„ì •" property="og:title">
  <meta content="https://accounts.kakaocdn.net/images/og_kakao.png" property="og:image">
  <script type="text/javascript" src="//t1.daumcdn.net/tiara/js/v1/tiara.min.js" defer></script>
  <link rel="preload" href="https://accounts.kakaocdn.net/_next/static/css/5b2b9d39fe4cdbec.css" as="style">
  <link rel="stylesheet" href="https://accounts.kakaocdn.net/_next/static/css/5b2b9d39fe4cdbec.css" data-n-g="">
  <link rel="preload" href="https://accounts.kakaocdn.net/_next/static/css/be4bd1d59789ef7d.css" as="style">
  <link rel="stylesheet" href="https://accounts.kakaocdn.net/_next/static/css/be4bd1d59789ef7d.css" data-n-p="">
  <link rel="preload" href="https://accounts.kakaocdn.net/_next/static/css/142faee8bf30c0d7.css" as="style">
  <link rel="stylesheet" href="https://accounts.kakaocdn.net/_next/static/css/142faee8bf30c0d7.css" data-n-p="">
  <noscript data-n-css=""></noscript>
  <script defer nomodule="" src="https://accounts.kakaocdn.net/_next/static/chunks/polyfills-5cd94c89d3acac5f.js"></script>
  <script src="https://accounts.kakaocdn.net/_next/static/chunks/webpack-2b7542ad6e55cb52.js" defer></script>
  <script src="https://accounts.kakaocdn.net/_next/static/chunks/framework-f8115f7fae64930e.js" defer></script>
  <script src="https://accounts.kakaocdn.net/_next/static/chunks/main-a7d45bce11193232.js" defer></script>
  <script src="https://accounts.kakaocdn.net/_next/static/chunks/pages/_app-2869068117262828.js" defer></script>
  <script src="https://accounts.kakaocdn.net/_next/static/chunks/29107295-f5d3d9a71e7e292a.js" defer></script>
  <script src="https://accounts.kakaocdn.net/_next/static/chunks/70368-58b0a348debb6a04.js" defer></script>
  <script src="https://accounts.kakaocdn.net/_next/static/chunks/74534-2f6ef9159b36b0df.js" defer></script>
  <script src="https://accounts.kakaocdn.net/_next/static/chunks/70224-dce93c8b726173b9.js" defer></script>
  <script src="https://accounts.kakaocdn.net/_next/static/chunks/3889-05e0d0b0c31484b5.js" defer></script>
  <script src="https://accounts.kakaocdn.net/_next/static/chunks/pages/login/login-454a9565927a45a1.js" defer></script>
  <script src="https://accounts.kakaocdn.net/_next/static/FVicjHfL7XJiYH-w2JepF/_buildManifest.js" defer></script>
  <script src="https://accounts.kakaocdn.net/_next/static/FVicjHfL7XJiYH-w2JepF/_ssgManifest.js" defer></script>
  <script src="https://accounts.kakaocdn.net/_next/static/FVicjHfL7XJiYH-w2JepF/_middlewareManifest.js" defer></script>
 </head>
 <body class="os_other pc type_responsive">
  <div id="__next" data-reactroot=""></div>
  <script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"pageContext":{"commonContext":{"locale":"ko","uaClass":"os_other  pc","responsiveView":true,"responsivePopup":false,"mobile":false,"webview":{"app":"web","webViewType":"none","appVersion":"","os":"other","osVersion":"","supportNavigation":false,"supportFilePicker":true,"supportExecUrlScheme":false,"supportMarketUrlScheme":true},"supportRefererMetaTag":false,"showHeader":true,"showFooter":true,"linkParams":{},"showDarkMode":null,"_csrf":"06d14c95-9710-4542-81a9-0470000f4c76","kage_file_max_size":100,"upload_kage_url":"https://up-api1-kage.kakao.com/up/kaccount-p/","p":"H13gBI_Wt92ZPrKJ3_NEqoTX8obV9yYthtDZwJsEIgg"},"context":{"webType":"web","defaultEmail":null,"showStaySignIn":true,"defaultStaySignIn":false,"appendStaySignedIn":false,"defaultCountryCode":"KR_82","showQrLogin":true,"showWebTalkLogin":false,"showDeviceFormLogin":false,"needCaptcha":false,"showIpSecurity":false,"loginUrl":"/login?continue=https%3A%2F%2Fkauth.kakao.com%2Foauth%2Fauthorize%3Fthrough_account%3Dtrue","continueUrl":"https://kauth.kakao.com/oauth/authorize?through_account=true","useSimpleLogin":true,"exceedSimpleLoginLimit":false,"defaultSaveSignIn":false,"isTalkLoginError":false,"linkParams":{"lang":["ko"]},"requests":{"check_daum_sso":["get","https://logins.daum.net/accounts/endpoint/favicon.ico"]}}}}},"page":"/login/login","query":{},"buildId":"FVicjHfL7XJiYH-w2JepF","assetPrefix":"https://accounts.kakaocdn.net","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script>
 </body>
</html>,[Date:"Tue, 03 Oct 2023 16:54:34 GMT", Content-Type:"text/html", Content-Length:"4540", Connection:"keep-alive", Vary:"Accept-Encoding", Cache-Control:"no-cache, no-store, must-revalidate", Pragma:"no-cache", Expires:"0", Set-Cookie:"_maldive_oauth_webapp_session_key=20ae36ddbef5f57862750bae8766a078; Path=/; HttpOnly", Kakao:"Talk", Server:"nginx", Strict-Transport-Security:"max-age=31536000", X-XSS-Protection:"1; mode=block", X-Content-Type-Options:"nosniff", Content-Security-Policy:"default-src 'self' *.kakao.com *.kakao.co.kr *.kakaocdn.net *.daum.net *.daumcdn.net *.melon.co.kr *.melon.com *.google.com *.gstatic.com aem-collector.daumkakao.io aem-ingest.onkakao.net; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.kakao.com *.kakao.co.kr *.kakaocdn.net *.daum.net *.daumcdn.net *.google.com *.gstatic.com; style-src 'self' 'unsafe-inline' *.kakao.com *.kakao.co.kr *.kakaocdn.net *.daum.net *.daumcdn.net *.google.com *.gstatic.com; frame-src *; font-src *; report-uri /reports/csp", Accept-CH:"Sec-CH-UA-Model,Sec-CH-UA-Full-Version-List,Sec-CH-UA-Platform-Version"]>

또한 Post로 호출하고 response를 출력하면 다음과 같은 응답결과가 나옵니다.

response = <302 FOUND Found,[Date:"Tue, 03 Oct 2023 17:07:35 GMT", Content-Length:"0", Connection:"keep-alive", Cache-Control:"no-cache, no-store, max-age=0, must-revalidate", Pragma:"no-cache", Expires:"0", X-XSS-Protection:"1; mode=block", X-Content-Type-Options:"nosniff", Referrer-Policy:"strict-origin-when-cross-origin", X-Frame-Options:"DENY", Location:"https://accounts.kakao.com/login?continue=https%3A%2F%2Fkauth.kakao.com%2Foauth%2Fauthorize%3Fthrough_account%3Dtrue", Kakao:"Talk", Access-Control-Allow-Origin:"*", Access-Control-Allow-Methods:"GET, POST, OPTIONS", Access-Control-Allow-Headers:"Authorization, KA, Origin, X-Requested-With, Content-Type, Accept"]>

인가 코드와 토큰은 모두 잘 받아와지며 백엔드를 통해 발급받은 token으로 postman을 통해 api 서버와 통신하면 사용자 정보를 잘 받아오는것을 확인하였습니다. 또한 로그아웃과 토큰 정보 보기 api 또한 카카오에서 제공하는 문서처럼 받아와 지는데 사용자 정보보기만 다음과 같은 문제들이 발생 하였습니다. 혹시 해결방법을 알 수 있을까요??

주소를 잘못 기재 하신 것 같네요.

사용자 정보 조회는 kapi.kakao.com 입니다.