question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

amplify storage returns 403

See original GitHub issue

Describe the bug Retrieving images using amplify-s3-image returns 403 forbidden.

I have no issue adding to s3 bucket via amplify-s3-image-picker retrieving throws a 403. I’ve tried adding files to public folder directly and trying to retrieve, returns 403 .

To Reproduce Steps to reproduce the behavior:

  1. setup auth amplify add auth
  2. setup api amplify add api
  3. setup storage amplify add storage -> auth users can create -> unauth/guest users can read.

Expected behavior display the image on app

Code Snippet

                <div class="my-8">
                  <amplify-s3-image-picker
                    button-text="yes"
                    header-title="Campaign Photo"
                    track="true"
                    :path="imgpath"
                  ></amplify-s3-image-picker>
                </div>
                <div>
                  <amplify-s3-image level="public" track="true" img-key="ball.png" />  //image uploaded directly to /public
                </div>

What is Configured? If applicable, please provide what is configured for Amplify CLI:

  • Which steps did you follow via Amplify CLI when configuring your resources.
  • Which resources do you have configured?
    • If applicable, please provide your aws-exports file:
    const awsmobile = {
        "aws_project_region": "us-east-1",
        "aws_cognito_identity_pool_id": "us-east-1:xxx-xxxx-xxxx-xxxx-xxxxxxxx",
        "aws_cognito_region": "us-east-1",
        "aws_user_pools_id": "us-east-1_xxx",
        "aws_user_pools_web_client_id": "xxxx",
        "oauth": {}
       "aws_appsync_graphqlEndpoint": "xx",
     "aws_appsync_region": "us-east-1",
     "aws_appsync_authenticationType": "AMAZON_COGNITO_USER_POOLS",
     "aws_user_files_s3_bucket": "xx",
     "aws_user_files_s3_bucket_region": "us-east-1"
    };
    

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
ashika01commented, Sep 11, 2020

Right here,

   "selectedGuestPermissions": [
        "s3:GetObject",
        "s3:ListBucket"
    ],
    "selectedAuthenticatedPermissions": [
        "s3:PutObject"
    ],

So in theselectedAuthenticatedPermissions, it says you have only given put permission. Can you try updating the storage to give get permissions there,

try amplify update storage and make sure to select both get and put for auth users. And lets see if that does the job.

1reaction
ShehryarKhcommented, Sep 12, 2020

@ashika01 Thank you. That was the issue. I’m not sure why it got set up that way. I got it to work by upgrading the storage to those permissions. Closing Issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS Amplify & React - Storage.put return 403 Forbidden
Authenticated roles can create/read/delete/list objects. Now, in my React application, when I do this: Storage.put(image.name, image, { level: ' ...
Read more >
Getting 403 while deploying your app through amplify, no ...
Getting 403 while deploying your app through amplify, no access to the buckets? Lost buckets. Here is the problem : https://github.com/aws ...
Read more >
Amplify Storage.put succeeds on iOS, throws axios 403 ...
Amplify Storage.put succeeds on iOS, throws axios 403 forbidden error on android (React Native) ... We have a react-native app that allows users...
Read more >
Developers - amplify storage returns 403 - - Bountysource
Retrieving images using amplify-s3-image returns 403 forbidden. I have no issue adding to s3 bucket via amplify-s3-image-picker retrieving ...
Read more >
Storage - File access levels - JavaScript - AWS Amplify Docs
When you run amplify add storage , the CLI will configure appropriate IAM policies on the bucket using a Cognito Identity Pool Role....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found