loginPage.html 2.16 KB
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8"/>
        <title>login page title</title>
        <script src="https://developers.kakao.com/sdk/js/kakao.js"></script>
               
    </head>
<body>
    <a id="kakao-login-btn"></a>
    <a href="http://developers.kakao.com/logout"></a>
    <script>
        Kakao.init('0678e32dab56db1c52ac63ab4ccb7663');
        
        console.log(Kakao.isInitialized());
        
        Kakao.Auth.createLoginButton({
            container: '#kakao-login-btn',
            success: function(authObj){
                console.log(JSON.stringify(authObj));
                alert(JSON.stringify(authObj));//authObj -> 토큰임.
                redirectUrl
            },
            fail: function(err){
                alert(JSON.stringify(err));
            }
        })
        console.log('hi');
    Kakao.Link.createDefaultButton({
        container: ".kakao-link",
        objectType: "feed",
        content:{
            title: "안녕하세요",
            description: "반갑습니다.",
            link:{
                webUrl: "https://www.naver.com/",
                mobileWebUrl: "https://www.naver.com/"
            },
        },
    })
        function kakaoLogout(){
            Kakao.Auth.logout(function(response){
                alert(response+'logout');
                Kakao.API.request({
                    url: '/v1/user/unlink',
                    success: function(response) {
                    console.log(response);
                    },
                    fail: function(error) {
                    console.log(error);
                    console.log("error");
                    },
                })
            })
        }
</script> 
<script>
    console.log('hi');
    Kakao.Link.createDefaultButton({
        container: ".kakao-link",
        objectType: "feed",
        content:{
            title: "안녕하세요",
            description: "반갑습니다.",
            link:{
                webUrl: "https://www.naver.com/",
                mobileWebUrl: "https://www.naver.com/"
            },
        },
    })
</script>

<a onclick="kakaoLogout();">카카오 로그아웃</a>
</body>
</html>