我想在我的网络上使用FireBase Auth, 我使用以下代码:
配置
var config = {
apiKey: "xxxxxxxxxxxxxxxxxxxx",
authDomain: "xxxxxxxxxxxxxxxxxxx",
databaseURL: "xxxxxxxxxxxxxxxxxxx",
projectId: "xxxxxxx",
storageBucket: "xxxxxxxxxxxxxxxx",
messagingSenderId: "xxxxxxxxxx"
};
设置提供商
firebase.initializeApp(config);
var GoogleAuthProvider = new firebase.auth.GoogleAuthProvider();
var FacebookAuthProvider = new firebase.auth.FacebookAuthProvider();
Google身份验证
function google(){
firebase.auth().signInWithPopup(GoogleAuthProvider).then(function(result) {
var token = result.credential.accessToken;
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;
// ...
});
}
Facebook身份验证
function facebook(){
firebase.auth().signInWithPopup(FacebookAuthProvider).then(function(result) {
var token = result.credential.accessToken;
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;
// ...
});
}
但是打开后,FireBase弹出窗口消失了。 我需要在哪里更改代码?” 我英文不好