I'm using Firebase Auth plugin for authentication of my Flutter app.
Until the upgrade (not sure if relevant) to the latest Firebase auth version:
firebase_core: ^0.5.0
firebase_auth: ^0.18.0+1
everything worked fine.
Now I got, for the first time, Sentry error:
FirebaseAuthException: [firebase_auth/user-token-expired] The user's credential is no longer valid. The user must sign in again.
File "exception.dart", line 20, in catchPlatformException
File "zone.dart", line 1198, in _rootRunUnary
File "zone.dart", line 1100, in _CustomZone.runUnary
File "future_impl.dart", line 160, in _FutureListener.handleError
File "future_impl.dart", line 708, in Future._propagateToListeners.handleError
File "future_impl.dart", line 729, in Future._propagateToListeners
File "future_impl.dart", line 537, in Future._completeError
File "async_patch.dart", line 47, in _AsyncAwaitCompleter.completeError
File "platform_channel.dart", in MethodChannel.invokeMapMethod
File "<asynchronous suspension>"
File "unparsed"
How can this happen? The user said, that he didn't use this app for a few days. As I understand Firebase Authentication documentation, the auth token automatically gets refreshed with the refresh token.
How can I mitigate this issue?
Where/how can I catch this exception to redirect a user to the login screen?