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个