<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Kakao login</title>
</head>
<body>

<a onclick="kakaoLogin();" href="javascript:void(0)">
	<button type="button"><img src="../resources/images/kakao_login_medium.png"/></button>
</a>

<!-- <a onclick="kakaoLogout();" href="javascript:void(0)">
          
</a> -->



<script src="https://developers.kakao.com/sdk/js/kakao.js"></script>
<script>
Kakao.init('965f16dea7d025318b70ff765ca81441');
console.log(Kakao.isInitialized());

//카카오로그인
function kakaoLogin() {
    Kakao.Auth.login({
      success: function (response) {
        Kakao.API.request({
          url: '/v2/user/me',
          success: function (response) {
        	  console.log(response)
          },
          fail: function (error) {
            console.log(error)
          },
        })
      },
      fail: function (error) {
        console.log(error)
      },
    })
  }
  
//카카오로그아웃  
function kakaoLogout() {
    if (Kakao.Auth.getAccessToken()) {
      Kakao.API.request({
        url: '/v1/user/unlink',
        success: function (response) {
        	console.log(response)
        },
        fail: function (error) {
          console.log(error)
        },
      })
      Kakao.Auth.setAccessToken(undefined)
    }
  }  
</script>
</body>
</html>