不確定爲何此代碼未運行。從Firebase複製了所有必需的片段,並且我的按鈕正在觸發。任何想法可能會出錯? Github讓我在這裏寫更多東西。Firebase身份驗證
謝謝!
<head>
<meta charset=utf-8 />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Auth</title>
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-database.js"></script>
</head>
<body>
<button onclick="googleAuth()">SIGN UP</button>
<script>
var provider = new firebase.auth.GoogleAuthProvider();
var googleAuth = function() {
console.log(firebase);
firebase.auth().signInWithPopup(provider).then(function(result) {
// This gives you a Google Access Token. You can use it to access the Google API.
var token = result.credential.accessToken;
// The signed-in user info.
var user = result.user;
// ...
}).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// The email of the user's account used.
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
// ...
});
};
</script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyBeJIaAAD5-vK0kBDTRH6Y6_1ByVE3erJY",
authDomain: "fir-chat-d28be.firebaseapp.com",
databaseURL: "https://fir-chat-d28be.firebaseio.com",
storageBucket: "fir-chat-d28be.appspot.com",
};
firebase.initializeApp(config);
</script>
</body>
我在瀏覽器中查看html文件,因此我無法在firebase中添加域。我也沒有在控制檯中得到任何錯誤。 – maxwellgover
瀏覽器中的域名是什麼? – Angelo
file:/// C:/Users/MGover/Desktop/index.html – maxwellgover