Firebase Web - Google 使用"redirect"选项登录,该选项不会重定向,但"popup"选项有效。我错过了什么?



我正在尝试为我的vuejs应用程序使用Firebase web使用Google登录。 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;
that.navToLogin();   //---> this works with signInWithPopup
});
firebase.auth().signInWithRedirect(provider).then(function(result) {
//user gets signed in but it does not redirect to a new page
that.navToLogin(); //---> this does not work
});
//Below didn't work either:
firebase.auth().signInWithRedirect(provider);
firebase.auth().getRedirectResult().then(function(result) {
if (result.credential) {
// This gives you a Google Access Token. You can use it to access the Google API.
var token = result.credential.accessToken;
that.navToLogin(); //---> this does not work
}
// The signed-in user info.
var user = result.user;
})

这似乎是重复的。您可以在此处获得有关重定向行为的说明:

Firebase Google 登录与重定向在成功进行身份验证后不会重定向到指定页面

相关内容

最新更新