Skip to content
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

Getting 403 error when trying to access public S3 bucket #790

Closed
matthewt-assurity opened this issue Jun 20, 2024 · 3 comments
Closed

Getting 403 error when trying to access public S3 bucket #790

matthewt-assurity opened this issue Jun 20, 2024 · 3 comments
Labels
question 🧐❓ Further information is requested

Comments

@matthewt-assurity
Copy link

Hello!

I'm trying to access a public S3 bucket, however I'm getting a 403 error.

Code I'm running:

s3 <- paws::s3()

bucket_name = "herbariumnsw-pds"

s3$list_objects_v2(
  Bucket = bucket_name,
  MaxKeys = 2
)

Exact response message:

Error: InvalidAccessKeyId (HTTP 403). The AWS Access Key Id you provided does not exist in our records.

The error makes it sound like I am trying to provide an access key ID, which I'm not explicitly, but I wonder if it is picking up on what is in my local AWS keys saved via running aws configure with the AWS CLI. Either way, I shouldn't need an access key to access a public S3 bucket, so I'm a bit confused.

For reference, I'm following this tutorial https://blog.djnavarro.net/posts/2022-03-17_using-aws-s3-in-r/. \

I am using paws instead of cloudyr, but I don't think this should make a difference as to whether I can access a public S3 bucket or not (I hope!).

@DyfanJones
Copy link
Member

Hi sorry to hear that, have you tried to setting anonymous? https://www.paws-r-sdk.com/docs/set_service_parameter/
I am currently having a holiday hence my slow replies.

@matthewt-assurity
Copy link
Author

Thanks @DyfanJones, I've updated my code to the below and it works!

s3 <- paws::s3(
  config = list(
    credentials = list(
      anonymous = TRUE
    )
  )
)

bucket_name = "herbariumnsw-pds"

objects <- s3$list_objects_v2(
  Bucket = bucket_name,
  MaxKeys = 2
)

I got a little stuck when I was using anonymous initially. I first tried to set this in the wrong function, i.e

objects <- s3$list_objects_v2(
  config = list(
    credentials = list(
      anonymous = TRUE
    )
  ),
  Bucket = bucket_name,
  MaxKeys = 2
)

@DyfanJones
Copy link
Member

@matthewt-assurity I'm glad you got it working. I will close this ticket. Feel free open again if the issue persists

@DyfanJones DyfanJones added the question 🧐❓ Further information is requested label Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question 🧐❓ Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants