Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

botocore.exceptions.ClientError An error occurred (SignatureDoesNotMatch) when calling the GetObject operation

While running the following code:

import boto3
BUCKET = 'bwd-plfb'

s3 = boto3.client('s3',use_ssl = False)

resp = s3.list_objects_v2(Bucket = BUCKET )

s3.download_file(BUCKET,'20171018/OK/OK_All.zip','test.zip')

I'm getting the following error:

   botocore.exceptions.ClientError: An error occurred 
   (SignatureDoesNotMatch) when calling the GetObject operation: The request 
   signature we calculated does not match the signature you provided. Check 
   your key and signing method.

What I've tried so far:

  1. Double checking Access key ID and Secret access key configured in aws cli (Running aws configure in command prompt) - They're correct.
  2. Trying to list bucket objects using boto3 - It worked successfully. The problem seems to be occuring when trying to download files.
  3. Using a chrome plugin to browse bucket contents and download files: chrome plugin It works successfully.

The interesting thing is downloading works for some files but not all. I downloaded a file which previously worked before 20 times in a row to see if the error was intermittent. It worked all 20 times. I did the same thing for a file which had not previously worked and it did not download any of the 20 times.

I saw some other posts on stackoverflow saying the api key & access key maybe incorrect. However, I don't believe that to be the case if I was able to list objects and download files (one's which did & did not work through boto3) using the Chrome S3 plugin.

Does anyone have any suggestions on what might be the issue here?

Thank You

like image 241
bodhisattva0743 Avatar asked Dec 27 '17 15:12

bodhisattva0743


1 Answers

this error occurs when you use wrong/invalid secret key for s3

like image 148
Ryabchenko Alexander Avatar answered Nov 17 '22 15:11

Ryabchenko Alexander