google-oauth-access-token-w.../callback/callback.html
2025-07-05 12:51:39 +09:00

34 lines
1.2 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>OAuth Callback</title>
</head>
<body>
<h2>처리 중입니다...</h2>
<script>
const hash = window.location.hash.substring(1); // '#access_token=...'
const params = new URLSearchParams(hash);
const accessToken = params.get("access_token");
if (accessToken) {
// 서버로 전송
fetch("/token", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ access_token: accessToken })
}).then((data) => {
document.body.innerHTML = "<h2>✅ Login Success!</h2>";
document.body.innerHTML += "<a href='/'>go to home</a>";
// 가져온 정보를 사용하여 아래에 정보 표시
document.body.innerHTML += "<h3>Access Token: " + accessToken + "</h3>";
document.body.innerHTML += "<h3>Email : " + data.email + "</h3>";
document.body.innerHTML += "<h3>Name : " + data.name + "</h3>";
document.body.innerHTML += "<h3>Profile Picture : " + data.picture + "</h3>";
});
} else {
document.body.innerHTML = "<h2>❌ Error: Access Token does not exist.</h2>";
}
</script>
</body>
</html>