Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When to do re-login after token expiration #1640

Open
pmpuro opened this issue Jan 25, 2024 · 3 comments · May be fixed by #1643
Open

When to do re-login after token expiration #1640

pmpuro opened this issue Jan 25, 2024 · 3 comments · May be fixed by #1643

Comments

@pmpuro
Copy link

pmpuro commented Jan 25, 2024

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

@nhachicha
Copy link
Collaborator

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.

@sync-by-unito sync-by-unito bot added the Waiting-For-Reporter Waiting for more information from the reporter before we can proceed label Jan 26, 2024
@pmpuro
Copy link
Author

pmpuro commented Jan 29, 2024

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.

@github-actions github-actions bot added Needs-Attention Reporter has responded. Review comment. and removed Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Jan 29, 2024
@nirinchev
Copy link
Member

@rorbech can you take over @cmelchior's PR?

@sync-by-unito sync-by-unito bot removed the Needs-Attention Reporter has responded. Review comment. label Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants