我正在使用Firebase的facebook signInWithRedirect,但无法弄清楚为什么我的应用程序无法导航到重定向的特定页面,而只是返回主页。我按照https://firebase.google.com/docs/auth/web/facebook-login上的步骤操作,并相信我已正确设置了所有内容。以下是我的登录代码:
$("#login").click(function() {
firebase.auth().signInWithRedirect(provider);
}
});
firebase.auth().getRedirectResult().then(function(result) {
if (result.credential) {
var token = result.credential.accessToken;
var user_data = result.user.providerData[0];
currentUid = user_data.uid;
var usersRef = firebase.database().ref().child('users');
usersRef.child(currentUid).once('value', function(snapshot) {
if (snapshot.val() !== null && snapshot.val().Phone !== undefined) {
localStorage.setItem("UID", currentUid);
localStorage.setItem("Name", user_data.displayName);
window.location = "/zones"; //Navigate to this route
} else {
var userDataJson = {
"Name": user_data.displayName,
"Email": user_data.email,
"Phone": user_data.phoneNumber
};
var childRef = usersRef.child(currentUid)
childRef.set(userDataJson).then(snap => {
localStorage.setItem("UID", currentUid);
localStorage.setItem("Name", user_data.displayName);
window.location = "/profile" ; //or Navigate to this route
});
}
});
}
}).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
console.log(errorMessage);
var email = error.email;
var credential = error.credential;;
});

在Firebase控制台中,我在授权域中列出了以下域: 1. localhost 2.我的firebase oauth域名 3.我的网站域名,我将在
上托管该应用在Facebook开发者控制台中,我在Valid OAuth重定向URI中列出了以下内容: 1。https://myblahblah.firebaseapp.com/__/auth/handler 2。https://mydomain/profile 3。https://mydomain/zones
我在这里做错了什么,一直试图弄清楚这几个小时!!