-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
46 lines (41 loc) · 1.76 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
39
40
41
42
43
44
45
46
<html lang="en">
<head>
<meta name="google-signin-scope" content="profile email">
<meta name="google-signin-client_id"
content="168837114669-ucclhidtfd6bh08tv0fsefajvoflh75u.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script>
</head>
<body>
<div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark"></div>
<button onclick="testEffect()">Fireflies</button>
<script>
function onSignIn(googleUser) {
// Useful data for your client-side scripts:
const profile = googleUser.getBasicProfile();
console.log("ID: " + profile.getId()); // Don't send this directly to your server!
console.log('Full Name: ' + profile.getName());
console.log('Given Name: ' + profile.getGivenName());
console.log('Family Name: ' + profile.getFamilyName());
console.log("Image URL: " + profile.getImageUrl());
console.log("Email: " + profile.getEmail());
// The ID token you need to pass to your backend:
const id_token = googleUser.getAuthResponse().id_token;
console.log("ID Token: " + id_token);
var xhr = new XMLHttpRequest();
xhr.open("POST", "/api/v1/on_login", true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify({
id_token: id_token
}));
}
function testEffect() {
var xhr = new XMLHttpRequest();
xhr.open("POST", "/api/v1/effects", true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify({
test: 'test'
}));
}
</script>
</body>
</html>