I am using python 3.5 with boto3==1.2.4 and botocore==1.3.29 on a Mac OSX Version 10.11.13.
I am experiencing the following issue:
An error occurred (SignatureDoesNotMatch) when calling the PutObject operation: The request signature we calculated does not match the signature you provided. Check your key and signing method.>
Here is the code:
self.session = Session(aws_access_key_id=self.api_key,
aws_secret_access_key=self.api_secret_key,
region_name=self.region_name)
self.s3_o = self.session.resource('s3')
bucket_o = self.s3_o.Bucket(container_name)
sample = "this should work"
bucket_o.put_object(Key='test1234', Body=sample)
What am I doing wrong? Thanks in advance for your help.
It looks like you're explicitly providing an access_key and secret_key. Can you confirm:
1) Do those credentials works for other S3 methods?
2) Do those credentials work for other non-S3 methods?
It is successful if I don't provide the access_key and secret_key explicitly to the Session class. I have setup the .aws directory in my home directory:
$ tree .aws
.aws
├── config
└── credentials0 directories, 2 files
I would like to parametrize it via environment variables and hence the keys are provided.
That would suggest that the access_key and secret_key you are providing to the session are not correct or are being modified in some way. I would double check the mechanism in which you're populating self.api_key and self.api_secret_key.
I've tried this out locally, and when I provide hard coded credentials to the Session object, I can confirm that they are being used as expected.
Apologies. My mistake! One character was missing for the secret key. It's working now. Thanks!
Apologies. My mistake! One character was missing for the secret key. It's working now. Thanks!
OH MY GOD, I CAN'T BELIEVE I MADE THIS MISTAKE TOO! Now I can finally drink some water.
2020 and I still reproduced this issue.
It's totally my bad but does anyone agree that the error message is misleading? What about an exception related to authentication and not object signature?
I also left the last character off...
Most helpful comment
Apologies. My mistake! One character was missing for the secret key. It's working now. Thanks!