benjreinhart / react-native-aws3

Pure JavaScript React Native library for uploading to AWS S3
MIT License
399 stars 151 forks source link

Credentials correct, Access Denied #25

Closed Johnafriedman closed 7 years ago

Johnafriedman commented 7 years ago

Hi Ben, Thanks for the library! I inherited a project that records and posts audio files to s3 and has a react web app and a react-native webview bridge app. The web app successfully uploads to s3 on desktop. The native app records a file, receives the credentials from the web app but always fails with on put with access denied. No error is generated in the console. Would you have any suggestions where I could look for a problem? Thanks ~john

benjreinhart commented 7 years ago

Hey @Johnafriedman,

This library works by generating the AWS signature needed to make the request. Assuming that

  1. your accessKey & secretKey are correct
  2. your IAM policy is correct

Then this library should generate the correct signature needed to make the request to AWS.

Unfortunately, it's really hard to tell what the error is when there is an access denied error given that something in the generated policy is off, but since it's a cryptographic signature, there is no way to tell (that I know of) which piece in the signature generation is incorrect besides eyeballing the source code over and over again looking for discrepancies between the code here and AWS docs on how to generate a signature.

There have been multiple mentions in other issues about generating policies on the server and I believe some others have forked this library to support server generated policies. I'm still waiting for PRs from anyone who has worked on improving this experience. However, I would want the existing repo to work as is, with additional functionality allowing users to opt in to server generated policies. I unfortunately don't do as much RN development at the moment, so I don't have as much incentive as I used to to spend my free time on this.

TLDR; I'm not sure I can help you debug your access denied issue. No one else has filed issues about AWS responding with access denied and it is still working in my production app, so it leads me to believe something with your particular credentials is causing problems rather than a bug in this library.

dsernst commented 7 years ago

I was curious about this too, so I looked into the forks to see if I could find what you were referring to. Here are two that seem to support attaching pre-created policies: