使用提供的非常簡單的簡單示例(Firebase Google Auth)我一直無法從Google獲得授權。好吧,我有,但並不總是意味着我實際上已經獲得了對象幾次...但如果我註銷ref.unauth()
它不會再工作。高低搜索我一直無法找到其他人經歷類似的事情。我必須失去一些東西。我真的不確定在這裏分享什麼來給予理解。這是我在頁面中的所有內容:Firebase Google Auth
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Contacts</title>
<script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script>
<script type="text/javascript">
var contactsRef = new Firebase('https://my-notreal-firebaseapp.firebaseio.com/contacts');
var authData = contactsRef.getAuth();
if (authData) {
console.log("User " + authData.uid + " is logged in with " + authData.provider);
} else {
console.log("User is logged out");
contactsRef.authWithOAuthRedirect("google", function(error,authData){
//do stuff post authentication
},{
remember: "sessionOnly",
scope: "email"
});
}
</script>
</head>
<body>
</body>
</html>
它每次重定向回登錄。我有多個Google帳戶,因此實際上我需要「選擇帳戶」頁面。我也設置了非常簡單的規則。
{
"rules": {
"contacts":{
".read": true,
".write": true
}
}
}
我仔細檢查過,以確保我在Google Developers Console和Firebase應用程序面板中正確設置了所有設置。
在此先感謝您的任何建議!
...和BTW ref.authWithOAuthPopup完美地工作。我很確定這個問題與重定向的錯誤處理有關。 –
從頁面返回後,您是否可以刷新並查看您是否已登錄? –
@DavidEast只是回到這...如果你刷新它嘗試再次認證。 –