Firebase Auth getIdToken在更新后被卡住 [英] Firebase Auth getIdToken gets stuck after update

查看:185
本文介绍了Firebase Auth getIdToken在更新后被卡住的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以情况如下:

1)用户已登录.上次生成的令牌是前一段时间,并且已过期.即使没有,问题也不会解决.

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)已安装应用程序更新. (不是android studio即时运行的东西,实际签名的apk具有更高的应用程序版本和appversioncode)

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

3)用户打开应用程序,然后运行常规代码,在该代码下我用来刷新id令牌.

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

4)没有一个听众受到打击,而且永远不会超时

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.

注意:我已将forceRefresh布尔值设置为false,因为此代码在每次启动应用程序时运行,并且我不希望不必要的id令牌创建被调用,以防世代限制.假布尔值仅在令牌过期时才刷新令牌.

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在进行所有检查之前,我确实进行了无效检查,以查看是否确实存在用户.

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

推荐答案

对于任何对此感到疑惑的人,我举了一张带有Firebase支持的票证,事实证明这是Firebase Auth 15.1.0中的错误

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.

根据我的测试,系统可以正常运行至12.0.1版本.如果您打算使用类似的功能,请不要更新到15.1.0.

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.

这篇关于Firebase Auth getIdToken在更新后被卡住的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆