-
Notifications
You must be signed in to change notification settings - Fork 0
/
signedin.html
55 lines (43 loc) · 1.37 KB
/
signedin.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
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Firebase ID Token Generator</title>
<style>
* {
box-sizing: border-box;
}
#idToken {
width: 100%;
}
</style>
</head>
<body>
<button onclick="getIdToken()">GET</button>
<button onclick="getIdToken(true)">GET (force new)</button>
<button onclick="copy()">Copy</button>
<button onclick="firebase.auth().signOut()">Sign Out</button>
<textarea id="idToken" rows="10" readonly onclick="this.select()">please wait...</textarea>
<script src="https://www.gstatic.com/firebasejs/7.11.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.11.0/firebase-auth.js"></script>
<script src="firebaseConfig.js"></script>
<script>
firebase.initializeApp(firebaseConfig);
firebase.auth().onAuthStateChanged(async user => {
if (user) getIdToken();
else window.location = 'index.html';
});
async function getIdToken(forceNew) {
document.getElementById('idToken').textContent = 'please wait...';
var idToken = await firebase.auth().currentUser.getIdToken(forceNew);
document.getElementById('idToken').textContent = idToken;
}
function copy() {
document.getElementById('idToken').select();
document.execCommand("copy");
alert('copied to clipboard');
}
</script>
</body>
</html>