UPDATE: Outh2 google
This commit is contained in:
33
outh2Test.html
Normal file
33
outh2Test.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<!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>
|
||||
Reference in New Issue
Block a user