You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm transitioning from AWSMobileClient to Amplify and it's a huge endeavor. I'm a bit stuck with handling session expiration cases and it might be a bug (or intended behavior, but then see the questions).
My app is configured to use auth user AND non-auth users.
So, let's assume in my Amplify.Hub.listen (...) I receive the sessionExpired event.
This leaves me in a totally inconsistent state, where, I would like to revert to a non-auth user and continue using the app. Or display something, doesn't matter.
But when I get the sessionExpired event, nothing works anymore: fetchAuthSession is dead, getIdentityId is dead, API calls are dead.
And the reason for that is that the fetchAuthSession returns isSignedIn = true and still has a user stalled somewhere.
The only way I could transition back to a non auth user is to call Amplify.Auth.signOut() and actually get rid of my bad user. After that, everything works again, I am a non-auth user.
This approach has one big problem: the user plays in the app and suddenly he gets the system dialog to sign in. We all know the issue with that text in the system dialog. It's really bad to just show this dialog out of the blue. And they might press CANCEL.
So... how can I get rid of the logged in user with the expired session ? Silently, not showing anything to the user.
PS: (Rant) The documentation is, again, completely useless, doesn't explain anything, doesn't give any actual real world examples. I'm using AWS for 10 years now and this was always the weak link. I expected Amplify to finally fix this issue, but unfortunately the documentation is just as useless as before.
PS2: Interestingly enough, on Android, according to my colleague, when he gets a sessionExpired in the Hub, calling fetchAuthSession magically fixes everything, session doesn't show signed in anymore and no user left to sign out and he's a non-auth user with a new identityId.
Steps To Reproduce
Kinda hard to provide some steps, it's a more generic theoretical question
Expected behavior
Either clean up the user when sessionExpires automatically and make sure we have an non-auth user working.
Provide another signOut() way without web. I use SSO and I need the cookies. This user is actually local, the session is dead anyway, so not really sure what a webpage is supposed to do with it and why it's needed to log out in this case.
Amplify Framework Version
2.45.2
Amplify Categories
Auth
Dependency manager
Swift PM
Platforms
iOS
The text was updated successfully, but these errors were encountered:
I discovered also an interesting behavior. So the session is dead and I call signOut(). I press CANCEL on the system dialog but the user is logged out and session can be fixed now, with fetch.
Which leads me to believe that signOut() has 2 parts: one on API side, web stuff, it works if there's a session valid, otherwise .... and one local part that cleans up the local user. The thing is that if the 1st part fails (or i press cancel), you still clean up local stuff and everything will work from now on.
At least there's that, but if I'm right, then you really should have a signOut() method that actually detects the session is dead so there's no point for any web stuff or any system dialog to be displayed and only do the local part.
And another thing. If the session expires when the app is opened, you have to handle the error from the API, which is nowhere to be found in the doc. Putting some prints when you detect an API error is not a documentation.
After digging around, I hope this is it:
if let apiError = error as? APIError {
switch apiError {
.......
case .operationError(let errorMessage, let recoverySuggestion, let underlyingError):
Describe the bug
I'm transitioning from AWSMobileClient to Amplify and it's a huge endeavor. I'm a bit stuck with handling session expiration cases and it might be a bug (or intended behavior, but then see the questions).
My app is configured to use auth user AND non-auth users.
So, let's assume in my Amplify.Hub.listen (...) I receive the sessionExpired event.
This leaves me in a totally inconsistent state, where, I would like to revert to a non-auth user and continue using the app. Or display something, doesn't matter.
But when I get the sessionExpired event, nothing works anymore: fetchAuthSession is dead, getIdentityId is dead, API calls are dead.
And the reason for that is that the fetchAuthSession returns isSignedIn = true and still has a user stalled somewhere.
The only way I could transition back to a non auth user is to call Amplify.Auth.signOut() and actually get rid of my bad user. After that, everything works again, I am a non-auth user.
This approach has one big problem: the user plays in the app and suddenly he gets the system dialog to sign in. We all know the issue with that text in the system dialog. It's really bad to just show this dialog out of the blue. And they might press CANCEL.
So... how can I get rid of the logged in user with the expired session ? Silently, not showing anything to the user.
PS: (Rant) The documentation is, again, completely useless, doesn't explain anything, doesn't give any actual real world examples. I'm using AWS for 10 years now and this was always the weak link. I expected Amplify to finally fix this issue, but unfortunately the documentation is just as useless as before.
PS2: Interestingly enough, on Android, according to my colleague, when he gets a sessionExpired in the Hub, calling fetchAuthSession magically fixes everything, session doesn't show signed in anymore and no user left to sign out and he's a non-auth user with a new identityId.
Steps To Reproduce
Kinda hard to provide some steps, it's a more generic theoretical question
Expected behavior
Amplify Framework Version
2.45.2
Amplify Categories
Auth
Dependency manager
Swift PM
Platforms
iOS
The text was updated successfully, but these errors were encountered: