33 lines
744 B
HTML
33 lines
744 B
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<title>Test Google OAuth</title>
|
|
</head>
|
|
<body>
|
|
<h2>Google OAuth Test</h2>
|
|
|
|
<button onclick="login()">Login with Google</button>
|
|
<button onclick="getProfile()">Call API (check login)</button>
|
|
|
|
<pre id="output"></pre>
|
|
|
|
<script>
|
|
const API = "http://localhost:3344";
|
|
|
|
function login() {
|
|
window.location.href = API + "/auth/google/login";
|
|
}
|
|
|
|
async function getProfile() {
|
|
const res = await fetch(API + "/users/current", {
|
|
method: "GET",
|
|
credentials: "include"
|
|
});
|
|
|
|
const data = await res.json();
|
|
document.getElementById("output").innerText = JSON.stringify(data, null, 2);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |