firebase access token expire in 4 to 5 hours

Viewed 535

I am making an chat app and use firebase phone authorization and quickblox chat api.

My code is:

private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {

                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {
                        // Sign in success, update UI with the signed-in user's information
                        Log.d("test", "signInWithCredential:success");
                        FirebaseUser mUser = FirebaseAuth.getInstance().getCurrentUser();

                        mUser.getToken(false).addOnCompleteListener(new OnCompleteListener<GetTokenResult>() {
                            @Override
                            public void onComplete(@NonNull Task<GetTokenResult> task) {
                                if(task.isSuccessful()){
                                    String m=task.getResult().getToken();
                                    signIn(m);
                                }
                            }
                        });


 public void signIn(String token){
       QBUsers.signInUsingFirebase(projectId, token).performAsync( new QBEntityCallback<QBUser>() {
        @Override
        public void onSuccess(QBUser user, Bundle args) {

            messenger.com.nowchat.helper.DataHolder.getInstance().setSignInQbUser(user);
            Intent intent = new Intent(Registration.this, WelcomeProfile.class);
            startActivity(intent);
             finish();
        }
}

But problem is that my token expires after 4 to 5 hours. When I clear the cache or reinstall the app then it works again for 5 hours.

2 Answers
Related