In Firebase 9.0.0 API, how to check the user has valid Auth session or not?

175 views
Skip to first unread message

Karthi R

unread,
May 24, 2016, 10:29:54 AM5/24/16
to Firebase Google Group

In legacy Firebase API, I was using "mFirebase.getAuth().getExpires()" to validate the user session. But in new Firebase 9.0.0 API, I couldn't find such validation.

Right now I'm checking the availability of Auth session as below,


public static boolean hasValidAuthToken() {
    return FirebaseAuth.getInstance().getCurrentUser() != null ? true : false;
}


How can I handle this, if the token got expired?


Thanks in advance!

Rahul Ravikumar

unread,
May 24, 2016, 1:33:21 PM5/24/16
to Firebase Google Group
You should not need to check for token expiry to check to see if you have a valid session.
If FirebaseAuth.getInstance().getCurrentUser() returns a non-null FirebaseUser instance, you should be good to go.
We will refresh tokens on your behalf when using other APIs. Also, when tokens refresh you will be notified via an event on (https://firebase.google.com/docs/reference/android/com/google/firebase/auth/FirebaseAuth.AuthStateListener).

Karthi R

unread,
May 25, 2016, 10:21:01 AM5/25/16
to Firebase Google Group
Thanks Rahul for your help!

Actually I'm using custom Authentication.
Reply all
Reply to author
Forward
0 new messages