簡體   English   中英

Firebase 身份驗證限制

[英]Firebase Authentication Limits

我是 Firebase 的新手,因此對任何見解表示贊賞。 我正在編寫 Java 服務器端測試代碼。 我從數據庫中獲取了幾個用戶,並嘗試將數據遷移到 Firebase 中的用戶身份驗證節點。 我的代碼從數據庫中選擇了一些用戶,並為每個用戶啟動一個新線程。

第一個線程連接並成功驗證。 隨后的同時身份驗證嘗試失敗並顯示以下錯誤消息。 每個線程都有自己的 Firebase 參考對象實例。 同時登錄的次數是否有限制,可能來自同一 IP 地址? 尚未在文檔中找到任何內容。

如果我將代碼更改為在單個線程中運行並一個接一個地登錄和注銷每個用戶,那么我不會收到錯誤消息。

任何見解都非常感謝。

Message: -5
Message: Due to another authentication attempt, this authentication attempt was aborted before it could complete.

            Firebase ref = new Firebase("https://<instance>.firebaseio.com/");

            ref.authWithPassword(mEmail, mPassword, new Firebase.AuthResultHandler() {
            @Override
            public void onAuthenticated(AuthData authData) {
                System.out.println("Successfully authenticated: " + mEmail);
                user.setUID(authData.getUid());
                user.setCurrentUserRef(ref);
                done.set(true);
            }

            @Override
            public void onAuthenticationError(FirebaseError firebaseError) {
                System.out.println("Error during authentication: " + mEmail);
                System.out.println("Error during authentication: " + ref.toString());

                System.out.println("Message: " + firebaseError.getCode());
                System.out.println("Message: " + firebaseError.getDetails());
                System.out.println("Message: " + firebaseError.getMessage());

                done.set(true);
            }});
            waitForCompletion(this.getClass().getName());

如果您因為安全規則而以不同用戶身份進行身份驗證,則使用服務器令牌是更好的解決方案。

Firebase 連接在任何給定時間最多只能對一個用戶進行身份驗證。 但是,在 Firebase Java 庫中,有一種未記錄(且未正式支持)的解決方法來創建多個獨立連接。 在包com.firebase.client的類中,您可以運行以下代碼

// important this code needs to be in the package com.firebase.client
Config config1 = new Config();
Config config2 = new Config();
Firebase ref1 = new Firebase("https://<your-firebase>.firebaseio.com", config1);
Firebase ref2 = new Firebase("https://<your-firebase>.firebaseio.com", config2);
// ref1 and ref2 will now have independent connections, listeners and authentication states

請注意,這些也將打開與服務器的獨立連接。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM