在Firebase 9.0.0 API中,如何检查用户是否具有有效的Auth会话? [英] In Firebase 9.0.0 API, how to check the user has valid Auth session or not?
问题描述
现在我正在检查Auth会话的可用性,
public static boolean hasValidAuthToken(){
return FirebaseAuth.getInstance()。getCurrentUser()!= null?真假;
$ b $ p
$ b 如果令牌过期,我该如何处理?
更新:
其实我正在做自定义身份验证。在服务器端拥有Firebase服务器sdk(java)。默认情况下,身份验证令牌将在1小时后过期。
在令牌过期后出现以下错误,
D / ConnectionRetryHelper:在398ms中安排重试
D / PersistentConnection:pc_0 - 尝试获取授权令牌
D / PersistentConnection:pc_0 - 获取令牌时出错:发生内部错误。 [ 内部错误。 ]
D / PersistentConnection:pc_0 - 计划连接尝试
如何处理这种情况?
感谢您的提前支持! 以保持令牌新鲜。
在讨论一位Google开发者分享了一个解决这个问题的指南。
$ b 指南: strong> https://drive.google.com/file/d/0B94LePkXiqa6SXVFd3N1NzJHX1E/view
它对我有效。
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?
Update:
Actually I'm doing custom Authentication. Having Firebase server sdk(java) at server side. By default, auth token will get expire after 1 hour.
Getting following error after token expired,
D/ConnectionRetryHelper: Scheduling retry in 398ms
D/PersistentConnection: pc_0 - Trying to fetch auth token
D/PersistentConnection: pc_0 - Error fetching token: An internal error has occured. [ Internal error. ]
D/PersistentConnection: pc_0 - Scheduling connection attempt
How can I handle this scenario?
Thanks in advance!
解决方案 Firebase latest version has an error to keep the token "fresh".
In this discussion a Google developer shared a guide to solve this problem.
Guide: https://drive.google.com/file/d/0B94LePkXiqa6SXVFd3N1NzJHX1E/view
It worked for me.
这篇关于在Firebase 9.0.0 API中,如何检查用户是否具有有效的Auth会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!