0

In Python I can access AWS and list files in bucket fine. But in R I get an error when trying to access AWS with the same credentials. Please help me debug the error.

R with error:

library(paws)
s3 <- paws::s3()
Sys.setenv(
    AWS_ACCESS_KEY_ID = "<key>",  
    AWS_SECRET_ACCESS_KEY = "<secret_key>",  
    AWS_DEFAULT_REGION = "us-east-1"  
)
s3$list_objects('<path>')

Error: SignatureDoesNotMatch (HTTP 403). The request signature we calculated does not match the signature you provided. Check your key and signing method.

Python with no error:

import s3fs
s3 = s3fs.S3FileSystem(
      key='<key>',
      secret='<secret_key>', 
      client_kwargs={
          'endpoint_url': 'https://s3.amazonaws.com', 
          'region_name':'us-east-1'
      }
    )
    s3.ls("<path>")
Frank
  • 952
  • 1
  • 9
  • 23
  • Perhaps https://stackoverflow.com/questions/30518899/amazon-s3-how-to-fix-the-request-signature-we-calculated-does-not-match-the-s Does your key start with a period? – Frank Yellin Oct 01 '21 at 16:57
  • There are no special characters in key. Also my system time is correct, I've seen that written around to check sys time. – Frank Oct 01 '21 at 16:58
  • The package in R takes a Bucket and Prefix for list_objects, not a S3 URI style path like s3fs takes for ls. – Anon Coward Oct 03 '21 at 18:12
  • @AnonCoward Is there an obvious way to transform the path to bucket/prefix? – Frank Oct 04 '21 at 13:02
  • In Python, you can use urlparse, in R, urltools could be used to get the host name (in the case of a S3 URL, the bucket) and the path. – Anon Coward Oct 04 '21 at 14:09
  • @AnonCoward Can you put an example of this as the answer? – Frank Oct 12 '21 at 15:45

0 Answers0