-
Notifications
You must be signed in to change notification settings - Fork 119
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
PutObjectOperationDeserializerKt.throwPutObjectError caused by S3Exception - The provided token has expired #2651
Comments
Can you paste your gradle dependencies here please? My suspicion is that you are trying to use both AWS SDK for Android and Amplify V2. While V1 was dependent on AWS SDK for Android there is no such dependency for Amplify V2. To add to that you definitely do need to refresh tokens even in guest scenarios, if you do a fetchAuthSession it should automatically do that for you. |
Hi! The dependencies are available in the original post. There are only:
The same dependencies were used with the previous v1.38.8. There were no code changes, no dependencies changes - only the version was updated. Apart from that, we have some lines in the project build.gradle, but I don't think they make a difference in this case:
Btw I did some more tests and currently I can say for sure that the problem appears only if you update the app from the version with AWS Amplify v1.38.8 to the new build with AWS Amplify v2.14.5. If I try to install a fresh new copy with AWS Amplify v2.14.5 all works as expected. As far as I can see, the problem doesn't appear in a tick of time after updating the app, but after some period. I'm not sure about the exact length, but looks like it's something about 1h. Anyway, a fresh new installation doesn't have the described issue and works well without any changes for longer periods of time. I've tried it for a couple of days and there were no such problems. |
Yes that makes sense as the refresh token is expired in that case. Can you try one more thing and advise what happens in the following scenario:
There could be an issue with migration and I would like to delve deeper to help you in this. |
Thx for the answer. I've added both fetchAuthSession and AndroidLoggingPlugin - the result is the same as previously. As far as I can see, fetchAuthSession receives credentials without any issues, nevertheless all uploads fail to finish. Here is the log:
|
I am going to locally try to reproduce this and get back to you. |
One question I had forgotten to ask before: is your device tracking enabled in your user pool ? |
Hmm... I'm not sure about this. As far as I know, this setting should be set by default. |
Gotcha. By default device tracking is not enabled but whenever the backend was configured if it was selected then it will be enabled. What happens in your upgrade if you sign out with forcesignout and then login ? Is the problem resolved ? |
Well, we're using guest accounts at this stage, as I wrote earlier. I'm not sure that it's possible to do "forcesignout and then login" in such case. If it isn't correct, give me more details, please. You can see the code snippet in the original message. |
Btw I want to bring your attention to the fact that the error itself is caused either by or by I can't reproduce the second cause, but I see it in our Firebase logs in quite big numbers. Probably, it's not just expiration issue rather something with the token handling. |
Yes you can do a forcesignout and then a fetchauthsession which will get you fresh guest credentials. The force signout will clean out all existing tokens. |
I couldn't find forcesignout, so I've used normal Amplify.Auth.signOut method. Looks like it works and locally I can't reproduce the issue anymore. We'll publish an update for the app soon. I'll be able to give more details after that. P.S. I'm not sure if it's related or not, but I've noticed this warning message in the logs after updating the app:
|
|
I saw @gpanshu closed this issue, but by the way @yaroslav-v the warning you mentioned is expected as we create an |
FYI I've been tracking the state of this issue for a while in Firebase and see than the number of reports has fallen significantly after the fix was applied in the project. However, there are still some reports appear on a daily basis (using the latest version of the library 2.14.10). I just want to point out that according to the docs AWS credentials for guest accounts should be refreshed automatically and the issue didn't exist for AWS Amplify v1 🤷♂️. There's the mentioned doc https://docs.amplify.aws/android/sdk/auth/ - "AWS Credentials ... For Guest scenarios they will be automatically refreshed." |
Before opening, please confirm:
Language and Async Model
Java
Amplify Categories
Authentication, Storage
Gradle script dependencies
Environment information
Please include any relevant guides or documentation you're referencing
https://docs.amplify.aws/android/sdk/auth/
Describe the bug
Hi there!
A part of our users experience issues with uploading images to AWS. The problem has appeared after updating from v1.38.8 to v2.14.5. The issue appears on all Android version from 9 to 14, affected devices include Samsung, Motorola, Oneplus, Google etc.
As far as I can see, this issue appears randomly on part of the devices only. I've tried to reproduce the issue locally but couldn't find exact steps.
You can find a crashlog from Firebase in the attachment. I've checked Firebase reports for the previous versions as well (before the update) and there were no such cases.
The crash itself is caused either by
Caused by aws.sdk.kotlin.services.s3.model.S3Exception
The provided token has expired.
or by
Caused by aws.sdk.kotlin.services.s3.model.S3Exception
The provided token is malformed or otherwise invalid.
As far as I understand from the docs and from my previous experience, we don't need to refresh tokens anyhow in this case - "For Guest scenarios they will be automatically refreshed."
Reproduction steps (if applicable)
Code Snippet
Log output
amplifyconfiguration.json
No response
GraphQL Schema
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: