Closed filippomenchini closed 2 years ago
Hello @filippomenchini - What is the refresh token expiration time set to in Cognito? By default it is 30 days, but can be changed to anything between 60 minutes and 10 years.
Once the refresh token expires, fetchAuthSession should throw an exception. The user will have to log back in with their username and password once it has expired.
Hi @Jordan-Nelson , thank you for your answer! I'll try with changing the refresh token expiration time.
I didn't get any exception from fetchAuthSession unfortunately. I'll try to play with that to see if I'm, handling the exception in a wrong way.
Thanks again!
I didn't get any exception from fetchAuthSession unfortunately.
Okay. You should get an exception. If we can get some reproducible steps then we can create a bug. If you can share the code in which you are calling this function and catching the exception I can see if I can reproduce that.
Hi @Jordan-Nelson sorry for the delay. Here's the code:
Future<Either<AuthFailure, String>> autoLogin() async {
try {
final session = await Amplify.Auth.fetchAuthSession();
if (!session.isSignedIn)
return Left(AuthFailure("User session has expired"));
final user = await Amplify.Auth.getCurrentUser();
return Right(user.userId);
} on AuthException catch (e) {
return Left(AuthFailure(e.message));
}
}
Let me know if there's something wrong with it, thank you! :)
@filippomenchini did updating the refresh token lifetime resolve your issue? To me, that sounds like the root of this problem.
Hi @dnys1 ! I've updated the refresh token lifetime. I think it's ok now, thanks!
Anyway, do you think that Amplify.Auth.fetchAuthSession() is working correctly?
I'm glad to hear it :) Please let me know if you experience any more issues.
Description
Hi! I'm experiencing some problems while uploading files to my bucket.
My users usually login the first time they open the app, then I use
to autologin them everytime they open the app.
The problem arises when a user that has been logged in for more than 30 days tries to upload an object to S3. To be able to upload the object, the user has to logout and login again.
Looking at the errors that I receive, It seems like the user after 30 days loses the permission to upload objects to the bucket.
Am I handling the autologin feature wrong? Is there an error with the Amplify library?
Thanks for your time!
Categories
Steps to Reproduce
Screenshots
No response
Platforms
Android Device/Emulator API Level
API 32+
Environment
Dependencies
Device
N/A
OS
N/A
CLI Version
9.1.0
Additional Context
No response