我在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/