const API_KEY = ${process.env.REACT_APP_REST_API_KEY}
;
const REDIRECT_URI = ${process.env.REACT_APP_REDIRECT_URI}
;
const KAKAO_AUTH_URI = https://kauth.kakao.com/auth/authorize?client_id=${API_KEY}&redirect_uri=${REDIRECT_URI}&response_type=code
;
window.location.href = KAKAO_AUTH_URI;
console.log(KAKAO_AUTH_URI);
const KakaoLogin = () => {
useEffect(() => {
const params = new URL(document.location.toString()).searchParams;
const code = params.get("code");
// const grant_type = "authorization_code";
const REDIRECT_URI = `${process.env.REACT_APP_REDIRECT_URI}`;
const API_KEY = `${process.env.REACT_APP_REST_API_KEY}`;
axios
.get(
`https://kauth.kakao.com/auth/token?grant_type=authorization_code&client_id=${API_KEY}&redirect_uri=${REDIRECT_URI}&response_type=code=${code}`,
{},
{
headers: {
"Content-type": "application/x-www-form-urlencoded",
},
}
)
.then((res) => {
console.log(res);
const { data } = res;
const { access_token } = data;
if (access_token) {
console.log(`Bearer ${access_token}`);
axios
.get(
"http://kapi.kakao.com/v2/user/me ",
{},
{
headers: {
Authorization: `Bearer ${access_token}`,
"Content-type": "application/x-www-form-urlencoded",
},
}
)
.then((res) => {
console.log("suc data");
console.log(res);
});
}
});
}, []); 코드인데 로그인하고 동의 하는데 까지는 되는데 not found 404가 뜹니다 경로 문제가 있는거같아 라우터 경로도 확인을 해보았으나 같은 오류가 나옵니다 uri는 http://localhost:3000/auth/kakao/callback