0

I’m trying out the Authentication component in Firebase.火力地堡驗證數據不匹配

A) I have a situation where the web client javascript code firebase-app.js and firebase-auth.js 3.3.0...

firebase.auth().onAuthStateChanged and firebase.auth().currentUser

... return different expected logged in user values, than the jvm client [com.firebase/firebase-client-jvm "2.5.2"]. The JVM client returns null user data.

My JVM client code is taken from Firebase’s QuickStart Guide . In the JVM client, neither onAuthStateChanged handler is called, nor does firebaseObj.getAuth() return any data.

I’m wondering where the discrepancy is. The web client was initialized with 「codepairio.firebaseapp.com」.

var config = { ...  authDomain: 「<my-firebase-app>.firebaseapp.com" 
    }; 
    firebase.initializeApp(config); 

B) The java client was initialized with 「https://.firebaseio.com」. I’m using this URL as it’s specified in the guide and mentioned here . Also, if you try to use 「.firebaseapp.com」, you’ll get an error: 「IllegalStateException For a custom firebase host you must first set your authentication server before using authentication features!」.

So with that out of the way, we have...

new Firebase("https://<my-firebase-app>.firebaseio.com」); 

Any ideas on how to get them to observe the same source of truth?

====> [編輯]

好的,我已經得到遠一點。事實證明,我使用的是比最新的(B)更老的Firebase API(A)。

A)https://www.firebase.com/docs/android/guide/user-auth.html

B)https://firebase.google.com/docs/auth/server/

因此,如果我們看一下Firebase's documentation對於如何處理用戶的,我們看到:

A Firebase User object represents the account of a user who has signed up to an app in your Firebase project. Apps usually have many registered users, and every app in a Firebase project shares a user database.

A Firebase User instance is independent from a Firebase Auth instance. This means that you can have several references to different users within the same context and still call any of their methods.

但我)的概念FirebaseAuth.getInstance().getCurrentUser()沒有意義,如果我們的應用程序正在處理多個用戶。而且,FirebaseAuth.getInstance().getCurrentUser()方法甚至不存在。 FirebaseAuth類文件(位於com.firebase/firebase-client-jvm「2.5.2」中)不反映the documentation

$ javap -classpath ~/.m2/repository/com/google/firebase/firebase-server-sdk/3.0.1/firebase-server-sdk-3.0.1.jar com.google.firebase.auth.FirebaseAuth 
Compiled from "FirebaseAuth.java" 
public class com.google.firebase.auth.FirebaseAuth { 
    public static com.google.firebase.auth.FirebaseAuth getInstance(); 
    public static synchronized com.google.firebase.auth.FirebaseAuth getInstance(com.google.firebase.FirebaseApp); 
    public java.lang.String createCustomToken(java.lang.String); 
    public java.lang.String createCustomToken(java.lang.String, java.util.Map<java.lang.String, java.lang.Object>); 
    public com.google.firebase.tasks.Task<com.google.firebase.auth.FirebaseToken> verifyIdToken(java.lang.String); 
    static com.google.api.client.json.JsonFactory access$000(); 
    static com.google.firebase.auth.internal.FirebaseTokenVerifier access$100(com.google.firebase.auth.FirebaseAuth); 
    static {}; 
} 

C)到目前爲止,使用火力地堡的身份驗證服務,在服務器上當時是非常不透明的給我。有人可以澄清處理多個用戶的語義,獲取登錄用戶的列表,用請求令牌驗證用戶等。工作API在哪裏?

回答

0

實際上,我從Firebase支持人員那裏得到了一個答案。原來,根據文檔,服務器端(nodejs和java)在身份驗證方面的可用功能僅爲i)創建自定義令牌和ii)驗證ID令牌。截至目前,處理用戶或獲取當前用戶尚不受支持。

有關在服務器端創建和驗證令牌的更多信息,請參閱this guide。您也可以查看這些帖子以獲取更多信息。

H個