Firebase: How to keep an Android user logged in?

前端 未结 4 1664
猫巷女王i
猫巷女王i 2021-02-05 11:53

I\'m using Firebase SimpleLogin to enable Email / Password authentication. Creation of users and subsequent login is all working fine. However, whenever I leave the app (even if

4条回答
  •  野性不改
    2021-02-05 12:42

    The proper way to do it is to use oAuth authentication:

    1. The user logs in.
    2. You generate an access token(oAuth2).
    3. Android app saves the token locally.
    4. Each time the comes back to the auth, he can use the token to to log in, unless the token has been revoked by you, or he changed his
    password.
    

    Luckily, firebase has an out of the box support for that, docs:

    https://www.firebase.com/docs/security/custom-login.html https://www.firebase.com/docs/security/authentication.html

提交回复
热议问题