-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
38 lines (38 loc) · 1.46 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>jaylol</title>
<link rel="stylesheet" href="./style.css">
<link rel="icon" href="./favicon.ico" type="image/x-icon">
</head>
<body>
<main>
<h1>jaylol</h1>
</main>
<script src="https://accounts.google.com/gsi/client" onload="console.log('TODO: add onload function')">
</script>
<script>
const code_receiver_uri = 'https://jaylol.com/code_receiver';
const client = google.accounts.oauth2.initCodeClient({
client_id: '117883256410-cj6gkhqi8ih2gs3245jpteo6cb8u8qvl.apps.googleusercontent.com',
scope: 'https://www.googleapis.com/auth/userinfo.email',
ux_mode: 'popup',
callback: (response) => {
const xhr = new XMLHttpRequest();
xhr.open('POST', code_receiver_uri, true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
// Set custom header for CRSF
xhr.setRequestHeader('X-Requested-With', 'XmlHttpRequest');
xhr.onload = function() {
console.log('Auth code response: ' + xhr.responseText);
};
xhr.send('code=' + response.code);
},
});
</script>
<button onclick="client.requestCode();">Authorize with Google</button>
</body>
</html>