Firebase user gets logged out after a couple of days

纵然是瞬间 提交于 2019-12-12 02:49:19

问题


I've added email&password, google, facebook authentication in my application. However, I noticed that after some time passes (1,2 days maybe) firebase.getAuth() returns null. Please note that I haven't called firebase.unauth() anywhere in the code, it seems like the authenticated session expires after some time. Is there a way to make the session not expire after few days? I can think of 2 solutions but both seem bad to me:

  • Store custom OAuthToken from Google, Facebook (maybe encrypted), email&password combo(worst case) and call the firebase.authWithOAuthToken() again and again when the session has become unauthorized
  • Bring the user back to login screen asking to perform the authorization again each time the session expires. I think this is even worse than the above because it breaks the UX and potentially upsets the majority of users.

Is there a built-in mechanism to achive the above? Thanks!


回答1:


Solution number 3 and also the cause of this issue. In your firebase dashboard on the Login & Auth tab you can set the session length, default is 24 or 48 hours i think.

So if it's set at 24 hours all sessions will expire after 24 hours like you are seeing right now. But you can change this to 6 months for example.



来源:https://stackoverflow.com/questions/36371065/firebase-user-gets-logged-out-after-a-couple-of-days

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