0
我有一個網絡應用程序,允許account.Once用戶已登錄用戶在使用他們的Gmail簽名,我能看到它的使用result.user對象的細節,如這個 -如何在使用Firebase的Web應用中的Google身份驗證之後獲取用戶詳細信息?
function signInWithGoogle(){
var provider=new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider).then(function(result){
var user=result.user;
console.log("user_provider="+user.displayName+" user_email="+user.email+" user_dp="+user.photoURL+" user_verification="+user.emailVerified+" uid="+user.uid);
}).catch(function(error){
console.log("error="+error);
});
}
簽訂後在,我想保持頁面的用戶詳細信息,甚至像這個 -
$(document).ready(function(){
var user=firebase.auth().currentUser;
console.log(user);
});
重裝並刷新了,我使用的身份驗證(的用戶對象)之後,但它顯示用戶爲空,雖然我會在身份驗證看到用戶電子郵件地址在火力點的控制檯。
P.S.我也使用onAuthStateChanged而不是currentUser,但它仍然不起作用。
意味着如果我在同一網站的不同頁面上使用onAuthStateChanged,那麼它會給用戶空值? –
這很清楚。它必須是相同的域。您是否期望在example1.com上登錄並在example2.com上獲得相同的用戶? – bojeil
不能從example1.com/page1.html登錄,並在example1.com/page2.html中獲取用戶詳細信息 –