-
Notifications
You must be signed in to change notification settings - Fork 247
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
Users getting session expired right after sign in #1271
Comments
Have some followup questions to better help you here:
|
Hi @fjnoyp
Also, my amplify versions:
|
@brunovsiqueira Do you know which devices these are occurring on? |
@haverchuck Samsung SM-G973F (Galaxy S10), SM-N770F (Galaxy Note 10 lite). Just letting you guys know, the same user who had this problem on SM-N770F (Galaxy Note 10 lite) tested on SM-N950F (Galaxy Note 20 FE) and it worked. So it seems to be linked with Samsung devices (?). Additionaly, a user who had the same problem but only reinstalled the app, continue having the problem. |
Could this explain the behavior you're seeing? |
Hi @dnys1. One of our users who reported the problem reinstalled the app from scratch. The behavior that we see in our logs is even stranger: 1- Because he reinstalled the App, he had no session so no SessionExpired was thrown. One thing that may be linked to the issue you mentioned is the fact that no exception is thrown when we call signIn, but instead it is thrown we try to fetch user session by calling fetchAuthSession (not sure if this behavior is expected, maybe yes). I don't think the issue you mentioned explains our problem, since even reinstalling the app the user gets SessionExpired when fetching session right after a "successful" sign in. |
Hmm okay, I will look into it more tomorrow. Does the object returned from the signIn call provide any info? I did try to reproduce this both in an emulator (Pixel) and a physical device (Galaxy S8) and for after the access token expired and after the access & refresh tokens expired. For all cases, I got the expected behavior. Unfortunately, I'm not sure what else to test for this.. these kinds of bugs are obviously very difficult to triage. |
Actually I don't have access to the signIn object in my logs. I think I am going to try to create an emulador which has same configurations of the mentioned devices (S10 and Note 10). I agree this bugs are very hard to reproduce. |
@dnys1 were you able to figure something out? |
Unfortunately, I haven't made any more progress @brunovsiqueira - I'm at a bit of a loss. Would you be willing to open a ticket with the amplify-android team with the same information? It's possible they may have some more insight as to what could be happening. |
We are having this problem as well. |
@dnys1 yes, I can. But it is happening in the flutter plugin. |
Indeed. The Amplify Flutter plug-in's functionality is built on top of Amplify Android which might be the root source of the problem. Just to confirm, the issue you encounter does not happen on iOS? |
@fjnoyp I haven't seen any of this issue' logs on iOS, so I assume it is not happening on iOS but I am not totally sure. |
@bwhiteTP is this problem happening for you only on Android as well? Do you have any information about the devices where it is happening? |
This does not happen to us on iOS, only Android. It also only seems to happen with sign in with email. It does't happen on sign up and it doesn't happen every time.
After I sign in with email and getting signed out a few more times it will just start working randomly. So the issue seems to fix itself after several tries. |
We don't use SSO and we only sign in our user using "username", not email. @bwhiteTP do you know in which device the error is happening? |
Complete logs:
|
Hi @brunovsiqueira @bwhiteTP thanks for sharing that information. Based on the information you've shared this sounds like an issue that is coming from the underlying Amplify Android library. Can you do what @dnys1 suggested and create an issue on the Amplify Android git repo? https://github.com/aws-amplify/amplify-android/issues |
I have created the issue on the Amplify Android git repo: aws-amplify/amplify-android#1635. |
Great thank you. We can monitor from there. |
Hi @Jordan-Nelson. Thanks for the update. Looking forward to hear back from you. |
I hope this message finds you well. I wanted to address the issue reported by @brunovsiqueira . I recently updated the library to version 1.10.0, but some users are still experiencing the same problem. Unfortunately, I don't have enough data at the moment to determine if the error rate has increased or decreased. I am actively seeking additional solutions and will continue to closely monitor the situation. Thank you for your understanding, and any further feedback would be greatly appreciated. |
@GarbielBarbosa thanks for letting us know. If you are able to get enough info to reproduce this issue, please let us know so that we can investigate further. If there is any info you can provide (devices, OSs, stack traces, etc.) that you think might help, please do provide it. |
@GarbielBarbosa Just to confirm, did you mean version 1.1.0? |
@Jordan-Nelson, I apologize for the mistake. I am using version 1.1.0 of the library.
Would this type of StackTrace be useful? |
@GarbielBarbosa The stack trace indicates the error is coming from the method channel implementation of fetchAuthSession. Version 0.x of Amplify wraps Amplify iOS and Android using method channels. This implementation is no longer present in version 1.x of Amplify is it has been re-written in Dart. Is it possible that the users that are experiencing this are using a version of your app that still uses version 0.x of Amplify? |
Hi, @Jordan-Nelson! I'd like to confirm if the correct method to obtain the tokens is as follows:
Our builds are performed through a pipeline. I truly believe that the version has already been updated with the new library version. Please review and confirm if my understanding is correct. If not, please clarify the correct method. Thank you in advance for your assistance! |
Hello, @Jordan-Nelson! Upon conducting a new search, I noticed that I obtained an incorrect build stack trace that used an outdated library. Please find below the new error stack trace. It appears to be a connection error, but according to the users, they are able to proceed with the login normally immediately after this error, indicating the need for a valid internet connection. I'm available for further information or clarification. |
@GarbielBarbosa - Yes, fetchAuthSession is the correct way to obtain the tokens. It could be that the users experiencing this have a spotty network connection that is causing only some requests to fail. You can handle the network exception case. A network exception indicates that the user's access/id tokes have expired, but the refresh token may still be valid (there is no way to determine the validity of the refresh token while offline). In the Authenticator UI component this case is handled as a valid session while the user is offline. Once they come back online if the refresh token has expired they will then be direct to sign in again. You can see how that is handled below. Lines 204 to 224 in 7949173
If you would like further assistance can you please open a new issue since it does not appear that the exception you are seeing is that same as what was reported in the original issue. |
I kindly request your assistance in reviewing the issue #3130. I would be immensely grateful if you could take a look at it and provide your analysis. Thank you for your attention and support. |
getting same issue |
@ilyasarafath the underlying exception in the logs you shared is different than what has been shared for this issue. I think it is likely a different issue. Can you open a new issue so that we can gather all the details about your issue? |
Hi there. |
Hi @brunovsiqueira - Apologies that this has been taking a while. There are two blockers from supporting these API levels that we are discussing internally:
It is unlikely that we will be able to support API 21/22 because of the blocker on EncryptedSharedPreferences. We are still discussing support for 23. If we were able to support 23, would this allow you to adopt Amplify flutter v1 or would lack of support for 21/22 still be a blocker? |
@brunovsiqueira - I just wanted to follow up with you and see if supporting API level 23 would unblock you from upgrading. As I had mentioned, I don't think supporting levels 21 & 22 will be possible because of the blocker on EncryptedSharedPreferences. |
Hi @Jordan-Nelson. Thank you for the follow-up. Unfortunately, we cannot upgrade the minSdkVersion to 23. We currently have 2,000 active users on API 21 and 22, and for now we cannot stop supporting them. |
Just to confirm, do you mean API 21 and 22? |
Exactly. Sorry for the confusion. I have just updated my comment. |
Okay. We are exploring supporting API 23. If you would like to see 21/22 supported in version 1.x, would you be willing to open a feature request? We can use that to track interest in support for those API levels. |
@brunovsiqueira - I think it makes sense to close this issue out as we believe this has been resolved in v1, and do not plan to address it in v0. If you would like, we can open a feature request to track interest in supporting a lower API level on Android. |
@brunovsiqueira - I am going to close out this issue. Please feel free to open a request for supporting a lower API level on Android in v1. Please let me know if you have any questions. |
Hi @Jordan-Nelson @dnys1, how are you? Our app is currently undergoing migration to support API level 23 (minSdkVersion 23). Is it possible for Amplify Flutter to also support API level 23? If so, we can proceed with migrating to version 1.x.x. This would be greatly appreciated by our team at BTG Pactual. Additionally, the need to support Amplify versions earlier than 1.0.0 has become a significant challenge due to its dependency on aws_common, which itself relies on http version 0.13.4. Consequently, we are unable to update any dependencies that have moved to http version 1.x.x. |
Hi @brunovsiqueira - You are look for Amplify V1 to support Android API level 23+ for the Auth category only, correct? You had previously asked about API levels 21/22. Are you only looking for API level 23+? Could you open a new feature request for this, and include those details? Thanks |
Thanks for the fast answer. Yes, I am looking for amplify_flutter, amplify_auth_cognito and amplify_core to support API 23. These are the dependencies we have. I am going to open a feature request. |
@Jordan-Nelson I have just created the feature request: #3739. |
Hi there.
We have two android users in production which are not being able to use our app because Amplify returns session expired right after signIn when we call
fetchAuthSession
.Inspecting this user's logs, what I see is the following:
1- We check user session by calling (
Amplify.Auth.getCurrentUser()
,Amplify.Auth.fetchAuthSession
) when the app is opened. We consider session expired ifInvalidStateException
orSessionExpiredException
is thrown and then we callAmplify.Auth.signOut()
if session has expired. In the mentioned case, this user session is considered expired and he is logged out.2- After that, the user called signIn successfully and "isSignedIn" flag returned true.
3- Right after signIn (sequentially),
Amplify.Auth.fetchAuthSession
is called in order to get user token (JWT) to call one of our APIs. When fetchAuthSession is called, this is the result according to the logs:(message: Your session has expired., recoverySuggestion: Please sign in and reattempt the operation., underlyingException: null)
Because user session has expired right after signIn, the user is not able to get the token and consequently is not able to consume none of our APIs.
This behavior is completely weird since the user has just logged in and is getting session expired. I was not able to reproduce it.
Since we have production users facing this problem, can anyone please help me understand/solve the problem?
The text was updated successfully, but these errors were encountered: