When to do re-login after token expiration
pmpuro opened this issue · comments
Problem
I've understanding that the app should implement an error handler and react on token expiration to keep the device sync going on. The piece of information the error handler gets is an exception that happed.
Which exception is it to which the app should react?
Solution
This could be a documentation issue.
Not sure if there's a missing exception derived from SyncException, which could indicate the need of re-login.
Alternatives
No response
How important is this improvement for you?
I would like to have it but have a workaround
Feature would mainly be used with
Atlas Device Sync
Hi @pmpuro the app currently throws a SyncException
that you can catch in the SyncConfiguration
error handler to redirect a user to the login screen again. This could be improved in the future to throw a subclass of SyncException
to make it more type safe.
- Conf example:
SyncConfiguration.Builder(schema = setOf(Foo::class), user = user)
.errorHandler(object : SyncSession.ErrorHandler {
override fun onError(session: SyncSession, error: SyncException) {
// handle error and redirect to login potentially
}
})
.build()
- Error example
io.realm.kotlin.mongodb.exceptions.SyncException: [Service][AuthError(4346)] Unable to refresh the user access token: invalid session: refresh token expired.
This could be improved in the future to throw a subclass of SyncException to make it more type safe.
This is exactly what I expected to find.
@rorbech can you take over @cmelchior's PR?