-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
AWSAccessKeyId set as undefined from Android platform but works correctly on iOS or browser #5332
Comments
Logs to notice are
Can you try reinstalling the app or completely clearing your android's app state and try again? |
Thank you for your answer. I tried deleting the app from the emulator, wiping data and doing a cold boot but that did not work. Is there anything else I could try? Many thanks! |
I'm able to see this exact same behavior when i run my deployed React app in IE or edge. The same app works fine in all other browsers. But in IE the
|
I managed to get around my issue by using the aws sdk and getting the signed URLs that way which worked on both Android and iOS but I would prefer to use amplify if possible, if anyone could get to the bottom of this problem. |
+1, I am also seeing this issue in IE and Edge |
I've detailed the issue here, your feedback is appreciated aws/aws-sdk-js-v3#1107 |
@russell-dot-js, fantastic debugging the issue and arriving at the root cause. And thank you for creating the issue with aws-sdk repository! |
@Amplifiyer for sure! I have a concern that the amplify-js and aws-sdk-js-v3 teams might have conflicting goals - see aws/aws-sdk-js-v3#1095 |
@alex-iancu, @russell-dot-js, can you confirm that the issue is fixed with the new amplify release? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems. |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Describe the bug
We developed an app using the MEAN stack. We integrated it with AWS S3 for data storage using Amplify by following this tutorial. We also enabled Auth in this step. We are not signing in the user, and we are only using the unauthenticated user in the app at this point.
When running the application on the iOS emulator or in the browser, the integration works fine, we can add files, list the files in the bucket and download the files. However, on android, in the result from Storage.get('filename'), the AWS access key ID is set to undefined. For example:
"https://bucketname.s3.eu-west-2.amazonaws.com/public/test.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=**undefined**%2F20200408%2Feu-west-2%2Fs3%2Faws4_request&X-Amz-Date=20200408T151352Z&X-Amz-Expires=900&X-Amz-Signature=bbad7466c769f40d6378d93ea86f77215b8ae011c30d3cc89a6ea2a452791c06&X-Amz-SignedHeaders=host&x-amz-user-agent=aws-sdk-js-v3-%40aws-sdk%2Fclient-s3%2F1.0.0-beta.3%20Mozilla%2F5.0%20%28Linux%3B%20Android%209%3B%20AOSP%20on%20IA%20Emulator%20Build%2FPSR1.180720.117%3B%20wv%29%20AppleWebKit%2F537.36%20%28KHTML%2C%20like%20Gecko%29%20Version%2F4.0%20Chrome%2F69.0.3497.100%20Mobile%20Safari%2F537.36%20aws-amplify%2F3.2.0%20js&x-id=GetObject"
As a result, when we try to download the file, the download fails and we receive the following error message:
[console.log]: "download failed: {\"code\":1,\"source\":\"https://bucketname.s3.eu-west-2.amazonaws.com/public/test.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=undefined%2F20200408%2Feu-west-2%2Fs3%2Faws4_request&X-Amz-Date=20200408T154640Z&X-Amz-Expires=900&X-Amz-Signature=f07580def29f83577f66b34128f7978763591af8c01a71d67fbc93af0b4f4ec5&X-Amz-SignedHeaders=host&x-amz-user-agent=aws-sdk-js-v3-%40aws-sdk%2Fclient-s3%2F1.0.0-beta.3%20Mozilla%2F5.0%20%28Linux%3B%20Android%209%3B%20AOSP%20on%20IA%20Emulator%20Build%2FPSR1.180720.117%3B%20wv%29%20AppleWebKit%2F537.36%20%28KHTML%2C%20like%20Gecko%29%20Version%2F4.0%20Chrome%2F69.0.3497.100%20Mobile%20Safari%2F537.36%20aws-amplify%2F3.2.0%20js&x-id=GetObject\",\"target\":\"file:///data/user/0/io.ionic.starter/files/\",\"http_status\":403,\"body\":\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n<Error><Code>InvalidAccessKeyId</Code><Message>**The AWS Access Key Id you provided does not exist in our records.**</Message><AWSAccessKeyId>undefined</AWSAccessKeyId><RequestId>E9925386223F5ACB</RequestId><HostId>BtCj7yyGeCkArqPyAx7ksOuMb2G91XmKQpSGTwjW8O05IEJuPSZIhBEwOgZfYHH+ypr56qkH8/Y=</HostId></Error>\",\"exception\":\"https://bucketname.s3.eu-west-2.amazonaws.com/public/test.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=undefined%2F20200408%2Feu-west-2%2Fs3%2Faws4_request&X-Amz-Date=20200408T154640Z&X-Amz-Expires=900&X-Amz-Signature=f07580def29f83577f66b34128f7978763591af8c01a71d67fbc93af0b4f4ec5&X-Amz-SignedHeaders=host&x-amz-user-agent=aws-sdk-js-v3-%40aws-sdk%2Fclient-s3%2F1.0.0-beta.3%20Mozilla%2F5.0%20%28Linux%3B%20Android%209%3B%20AOSP%20on%20IA%20Emulator%20Build%2FPSR1.180720.117%3B%20wv%29%20AppleWebKit%2F537.36%20%28KHTML%2C%20like%20Gecko%29%20Version%2F4.0%20Chrome%2F69.0.3497.100%20Mobile%20Safari%2F537.36%20aws-amplify%2F3.2.0%20js&x-id=GetObject\"}"
We turned on the window log level to debug and this is the output from the android emulator:
[ng] [console.log]: "[DEBUG] 46:40.366 Credentials - getting credentials" [ng] [console.log]: "[DEBUG] 46:40.366 Credentials - picking up credentials" [ng] [console.log]: "[DEBUG] 46:40.367 Credentials - getting new cred promise" [ng] [console.log]: "[DEBUG] 46:40.367 Credentials - checking if credentials exists and not expired" [ng] [console.log]: "[DEBUG] 46:40.368 Credentials - need to get a new credential or refresh the existing one" [ng] [console.log]: "[DEBUG] 46:40.372 AuthClass - Getting current user credentials" [ng] [console.log]: "[DEBUG] 46:40.384 AuthClass - Getting current session" [ng] [console.log]: "[DEBUG] 46:40.391 AuthClass - Failed to get user from user pool" [ng] [console.log]: "[DEBUG] 46:40.397 AuthClass - Failed to get the current user" "No current user" [ng] [console.log]: "[DEBUG] 46:40.400 AuthClass - getting session failed" "No current user" [ng] [console.log]: "[DEBUG] 46:40.404 Credentials - setting credentials for guest" [ng] [console.log]: "[DEBUG] 46:40.841 Credentials - Failed to load credentials" { [ng] "__zone_symbol__state": false, [ng] "__zone_symbol__value": { [ng] "$metadata": { [ng] "retries": 0, [ng] "totalRetryDelay": 0 [ng] } [ng] } [ng] } [ng] [console.log]: "[DEBUG] 46:40.849 AWSS3Provider - set credentials for storage" {} [ng] [console.log]: "[DEBUG] 46:40.868 AWSS3Provider - get test.png from public/test.png"
When doing the same thing on the ios app, the download succeeds and the result of the logger is:
[ng] [console.log]: "[DEBUG] 53:44.730 Credentials - getting credentials" [ng] [console.log]: "[DEBUG] 53:44.730 Credentials - picking up credentials" [ng] [console.log]: "[DEBUG] 53:44.731 Credentials - getting new cred promise" [ng] [console.log]: "[DEBUG] 53:44.731 Credentials - checking if credentials exists and not expired" [ng] [console.log]: "[DEBUG] 53:44.731 Credentials - need to get a new credential or refresh the existing one" [ng] [console.log]: "[DEBUG] 53:44.732 AuthClass - Getting current user credentials" [ng] [console.log]: "[DEBUG] 53:44.735 AuthClass - Getting current session" [ng] [console.log]: "[DEBUG] 53:44.741 AuthClass - Failed to get user from user pool" [ng] [console.log]: "[DEBUG] 53:44.741 AuthClass - Failed to get the current user" "No current user" [ng] [console.log]: "[DEBUG] 53:44.742 AuthClass - getting session failed" "No current user" [ng] [console.log]: "[DEBUG] 53:44.743 Credentials - setting credentials for guest" [ng] [console.log]: "[DEBUG] 53:45.31 Credentials - Load credentials successfully" { [ng] "accessKeyId": "ASIA....", [ng] "secretAccessKey": "XXXX", [ng] "sessionToken": "IQoJb3....", [ng] "expiration": "2020-04-08T16:53:44.000Z" [ng] } [ng] [console.log]: "[DEBUG] 53:45.33 AWSS3Provider - set credentials for storage" { [ng] "accessKeyId": "ASIA....", [ng] "sessionToken": "IQoJb3...", [ng] "secretAccessKey": "XXXX", [ng] "identityId": "eu-west-2:bd0a0c9f-d8fd-4ea2-a405-c4a75b8d95c3", [ng] "authenticated": false [ng] } [ng] [console.log]: "[DEBUG] 53:45.34 AWSS3Provider - get test.png from public/test.png"
Expected behavior
Expect the result fron Storage.get function call to be the same on iOS and android.
Environment
Smartphone (please complete the following information):
Additional context
There is a lot more info in the debug from the console, but not sure which of it is relevant, so please let me know if I should provide any more.
The text was updated successfully, but these errors were encountered: