首页 > 解决方案 > 使用谷歌登录后重定向到另一个页面 - Firebase Web

问题描述

一切正常。使用谷歌登录正在工作。我想知道我需要在我的 googlesignin 函数中添加什么,以便在使用 google 登录后,它被重定向到 facebook.html 页面?

按钮代码 <button onclick="googleSignin()">Google Signin</button>

 function googleSignin(){
   base_provider = new firebase.auth.GoogleAuthProvider()
   firebase.auth().signInWithRedirect(base_provider).then(function(result){
      console.log(result)
      console.log("Success.. Google Account Linked")
   }).catch(function(err){
      console.log(err)
      console.log("Failed to do")
   })
}

标签: javascriptfirebaseweb

解决方案


我找到了答案,我想和大家分享。

function googleSignin(){
   base_provider = new firebase.auth.GoogleAuthProvider()
   firebase.auth().signInWithPopup(base_provider).then(function(result){ 
     window.location="facebook.html";
      console.log(result)
      console.log("Success.. Google Account Linked")
   }).catch(function(err){
      console.log(err)
      console.log("Failed to do")
   })
}

推荐阅读