I want to allow users of my app to sign in anonymously (that will create an account for them with a randomly generated email & password), and if and when they'll want to create a permanent account, they will be able to simply bind an email & password.
I work with tokens, access and refresh, which means the regular tokens flow is the same for both anonymous and authenticated users.
The problem with anonymous users is what if a user didn't logged in to the app for a long amount of time (that is larger than the refresh token) which means that now the refresh token is expired and invalid.
How could I handle such case? I couldn't ask them for a reauthentication as usual because they don't know they're credentials, and I can't risk to lose the user's data.
Only thing I could think of is to try and save their credentials securely with encryption using local preferences such as DataStore/SharedPreferences combined with KeyStore, and when such case does happens, I'll simply relogin them. But I'm not sure if that's good enough.
Any suggestions are much appreciated!