javascript - Firebase google 登录弹出窗口闪烁并且从不使用 Vuejs 登录?

标签 javascript firebase vue.js firebase-authentication google-signin

我在vuejs中使用了google sign in popup方法。在实时谷歌登录中,弹出窗口闪烁并且从未登录。但在本地一切正常。

这是 firebase google 登录和注册方法代码:

 const database = firebase.initializeApp(config);

 const firestore = database.firestore();

 var provider = new firebase.auth.GoogleAuthProvider();

 database.signIn = async (email, password) => {

   try {
   await firebase.auth().signInWithPopup(provider).then((result) => {
  // This gives you a Google Access Token. You can use it to access Google API.
  var token = result.credential.accessToken;
  // The signed-in user info.
  var user = result.user;

  console.log("user",user.displayName);
  console.log('result google',result.user);
  // ...
  store.commit("setCurrentUser", 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;
        // ...
      });

      return true;
     } catch (error) {
      return error;
    }
  }

尝试更改 chrome 弹出窗口,cookie 设置无效。非常感谢任何帮助...

最佳答案

如果它在本地运行,您应该确保您的托管域已在 Google OAuth 中注册。

在 Firebase 控制台中:

开发->认证->登录方式->授权域

并将您的域添加到列表中。可能需要一些时间来验证。

如果这不起作用,请尝试记录 error.message 以获取更多信息。

关于javascript - Firebase google 登录弹出窗口闪烁并且从不使用 Vuejs 登录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56684375/

相关文章:

javascript - 解析未捕获的类型错误: Cannot read property 'get' of undefined

javascript - 如何在 html 上以列表形式显示 firebase 查询结果?

ios - 如何检查 Firebase 中是否存在用户名

javascript - Angular POS 应用程序,尝试从 POJO 生成自动采购订单

javascript - Vuetify - 如何自定义 <v-select> 中的选项样式?

javascript - 为什么我的 Bootstrap 3.1.1 'Collapse' 元素会自动关闭?

java - 将数据传递到 jquery 的 getJSON() 时出现问题 - 不接受 map

javascript - 在第 n 次出现的字符处剪切字符串

javascript - NuxtJS页面标题不变

javascript - NUXT 中间件中未定义 Vuex store