FirebaseError:无法解析身份验证令牌-7

时间:2017-09-26 10:04:50

标签: android firebase firebase-realtime-database firebase-authentication jwt

我正在尝试应用自我服务器在使用firebase注册/登录时从我的服务器接收的自定义身份验证令牌,以从firebase数据库中获取数据。但是,我在对firebase的身份验证调用时遇到了以下错误。

FirebaseError: Could not parse auth token.

{"t":"d","d":{"r":1,"b":{"s":"invalid_token","d":"Could not parse auth token."}}}

以下是我的代码

private void checkForDataRead() {
    authFirebaseRef = new Firebase(ApiConstants.FIREBASE_MY_URL);
    authFirebaseRef.authWithCustomToken(AppConstants.FBT, authResultHandler);
    letsFetch();
}

private void letsFetch() {
    authFirebaseRef.getRoot().child("sos/emergengyServicesName").addValueEventListener(new com.firebase.client.ValueEventListener() {
        @Override
        public void onDataChange(com.firebase.client.DataSnapshot dataSnapshot) {
            Log.v("onDataChange", ":" + dataSnapshot.child("emergencyServicesName").getValue());
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {
            Log.v("DatabaseError", firebaseError.getMessage());
        }
    });
}

Firebase.AuthResultHandler authResultHandler = new Firebase.AuthResultHandler() {
    @Override
    public void onAuthenticated(AuthData authData) {
        Log.v("onAuthenticated", authData.getUid());
        letsFetch();
    }

    @Override
    public void onAuthenticationError(FirebaseError firebaseError) {
        Log.v("onAuthenticationError= ", "FirebaseError= " + firebaseError.toString());
    }
};

0 个答案:

没有答案