Firebase Auth getIdToken gets stuck after update

巧了我就是萌 提交于 2019-12-10 18:17:00

问题


So the situation is as follows:

1) A user is logged in. the last token generated was a while ago and has expired. even if it hasn't, the issue doesn't hit.

2) An app update is installed. (Not android studio instant run thing, Actual signed apk with a higher app version and appversioncode)

3) User opens app and the regular code below which i use to refresh the id token runs.

4) None of the listeners get hit and there's never a time out

Is this a bug or am i doing something wrong here?

Clearing app data and restarting clears all problems. The code runs fine in this case. It only gets stuck after an update.

NOTE: i have set the forceRefresh boolean false as this code runs on every app launch and i don't want unnecessary id token creations getting called in case there's a limit on the generations. the false boolean does refresh the token if and only if it has expired.

                FirebaseAuth.getInstance().getCurrentUser().getIdToken(false).addOnCompleteListener(new OnCompleteListener<GetTokenResult>() {
                    @Override
                    public void onComplete(@NonNull Task<GetTokenResult> task) {

                        if (task.isSuccessful()) {
                          //logic to proceed further
                        }


                }).addOnFailureListener(new OnFailureListener() {
                    @SuppressLint("SetTextI18n")
                    @Override
                    public void onFailure(@NonNull Exception e) {

                        if(e instanceof FirebaseAuthInvalidUserException){

                            //Do stuff to log out the user session

                        }else{

                            //Some other exception occurred, let the user retry      

                        }


                    }
                });

P.S i do have a nullity check before all this to see if there indeed is a user.


回答1:


For anyone wondering about this, I raised a ticket with Firebase support and it turns out that it's a bug in Firebase Auth 15.1.0

According to release notes, they had modified the token refresh logic and probably this is where the bug was introduced.

The system works fine up to 12.0.1 version according to my tests. Please do not update to 15.1.0 if you are planning to use a similar feature.



来源:https://stackoverflow.com/questions/50222500/firebase-auth-getidtoken-gets-stuck-after-update

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!