-
Notifications
You must be signed in to change notification settings - Fork 6
/
signin_with_pop-up_window.html
executable file
·35 lines (32 loc) · 1.28 KB
/
signin_with_pop-up_window.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Firebase Authentication SDK Google 登入</title>
<script src="https://www.gstatic.com/firebasejs/3.2.0/firebase.js"></script>
<script>
// 初始化 Firebase
var config = {
apiKey: "你的 API Key",
authDomain: "myfirebaseproject-57619.firebaseapp.com",
databaseURL: "https://myfirebaseproject-57619.firebaseio.com",
storageBucket: "myfirebaseproject-57619.appspot.com",
};
firebase.initializeApp(config);
var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider).then(function(result) {
var token = result.credential.accessToken;
var user = result.user; // 使用者資訊
}).catch(function(error) {
// 處理錯誤
var errorCode = error.code;
var errorMessage = error.message;
var email = error.email; // 使用者所使用的 Email
var credential = error.credential;
});
</script>
</head>
<body>
<h1>Firebase Authentication SDK Google 登入</h1>
</body>
</html>