firebase.auth().signInWithPopup(provider)
不起作用,没有在Firebase中登录,我不知道是什么,控制台打印:
对象{代码:“auth / operation-not-supported-in-thi ...”,消息:“此操作不支持...”,stack:“”}
function toggleSignIn() {
if (!firebase.auth().currentUser) {
console.log("!firebase.auth().currentUser yes");
var provider = new firebase.auth.FacebookAuthProvider();
provider.addScope('user_birthday');
firebase.auth().signInWithPopup(provider).then(function(result) {
console.log("!firebase.auth().currentUser yes");
var token = result.credential.accessToken;
var user = result.user;
document.getElementById('quickstart-oauthtoken').textContent = token;
}).catch(function(error) {
var errorCode = error.code;
var errorMessage = error.message;
var email = error.email;
var credential = error.credential;
if (errorCode === 'auth/account-exists-with-different-credential') {
alert('You have already signed up with a different auth provider for that email.');
} else {
console.error(error);
}
});
} else {
firebase.auth().signOut();
}
document.getElementById('quickstart-sign-in').disabled = true;
}
答案 0 :(得分:0)
首先:您是否可以在Firebase控制台中检查您是否已完全启用Facebook:如果您按照转到https://console.firebase.google.com/project/_/authentication/providers并选择您的应用,请检查Facebook部分是否具有从Facebook控制台配置的相应值。
第二:确保从Web服务器运行。 Firebase Hosting是一种在本地运行的好方法(getters
,firebase init
),但任何网络服务器都可以。 signInWithPopup不能在刚刚在浏览器中打开的文件中工作。