generate_presigned_url no longer works, gives: SignatureDoesNotMatch
See original GitHub issueimport boto3,requests,os
def get_session():
access_key = os.getenv('JAR_LAMBDA_ACCESS_KEY')
secret_key = os.getenv('JAR_LAMBDA_SECRET_KEY')
if None in [access_key, secret_key]:
raise Exception('KEYs not set')
session = boto3.Session(aws_access_key_id=access_key, aws_secret_access_key=secret_key, region_name='eu-central-1')
return session
def print_url():
key = 'mykey'
bucket = 'mybucket'
try:
session = get_session()
s3 = session.client('s3', config=boto3.session.Config(signature_version='s3v4'), region_name='eu-central-1')
url = s3.generate_presigned_url(ClientMethod='get_object', Params={'Bucket': bucket, 'Key': key}, ExpiresIn=3600)
print(url)
resp = requests.get(url)
print(resp)
except Exception as e:
print(e)
The browser gives a 403 and:
<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>
The request signature we calculated does not match the signature you provided. Check your key and signing method.
</Message>
...
Signing with:
aws s3 presign s3://mybuket/mykey --expires 1800 --profile presigner
works perectly. The presigner profile has the same keys as the python code above.
Versions: Python 3.7.0 (had the same issue with 3.6.*) boto3-1.7.70 botocore-1.10.70 s3transfer-0.1.13
Please also read this: https://stackoverflow.com/questions/50213740/aws-s3-presigned-urls-with-boto3-signature-mismatch
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:20 (2 by maintainers)
Top Results From Across the Web
Boto3 generate_presigned_url, SignatureDoesNotMatch error
I know this is a bit late to answer, but I solved my problem by following the method as specified in this GitHub...
Read more >The request signature we calculated does not match ... - Reddit
SignatureDoesNotMatch - The request signature we calculated does not match the signature you provided. Check your key and signing method.
Read more >S3 Signature Does Not Match Error When Using A Pre Signed ...
So I made my pre signed url using the AWS SDK: $cmd = $s3Client->getCommand('PutObject', array( 'Bucket' => $bucket, 'Key' => $key )); $request ......
Read more >R2 storage: unable to upload using pre-signed url, getting ...
I am using boto3 to generate pre-signed URL. ... Posting to the URL is not working the way it's described in the boto3...
Read more >Access files from AWS S3 using pre-signed URLs in Python
A pre-signed URL gives you **temporary **access to the object identified in the URL, ... The URL throws a signature does not match...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@imperio59 's answer helped, but I also needed to set
signature_version='s3v4'
:boto3 1.9.28 (1.9.34 is latest available) botocore 1.12.28 (1.12.34 is latest available) python 3.6.4 (MacOS)
Thanks @Trogious ! We had the same issue
SignatureDoesNotMatch
uploading an image from our React Native APP.I fixed it passing the
signature_version='s3v4'
and theregion_name