KaKao Oauth
- 공식문서를 보면서 우리 백앤드와 진행을 했다
- 하지만..이게맞는코드인지 아직 실험이 안됐는데 일단 끄적여본다
useEffect(() => {
axios
.get<KakaoOAuthResponse>(Kakao_Auth_Url, {
params: {
code: new URLSearchParams(window.location.search).get("code"),
},
})
.then(async (res) => {
setTest(res.data);
const request = {
grant_type: "authorization_code",
client_id: Rest_API_Key,
redirect_uri: Redirect_Uri,
code: res.data,
};
await axios
.post("kauth.kakao.com/oauth/token", qs.stringify(request), {
headers: { "Content-Type": "application/x-www-form-urlencoded" },
})
.then((res) => {});
})
.catch((error) => {
console.error("Failed to exchange auth code for access token", error);
});
}, []);
return (
<>
<button
className="KaKao_Oauth_Button"
onClick={() => {
window.open(Kakao_Auth_Url, `authForm`, "width=570, height=350");
console.log(test);
}}
>
K
</button>
</>
);
};
- 인가코드를 받아서 실행시키는건데 .. 저걸 클릭했을때 함수로 넘겨줘야 할꺼같다 근데 어떤식으로 넘겨야 할지 감은 안오는상태..