AWS S3 presigned urls with boto3 – Signature mismatch

Question:

I want to create a presigned url for the objects in my bucket. I use the following python code:

I then send the generated URL to my frontend. On the client I will create an a tag with the generated link and use the click() method on it. This worked fine in other projects but here I only get the error:

Which is strange. The user should have all the necessary rights. Because listing all the files in my bucket works fine.

Can someone point me in the right direction why this isn’t working?

EDIT

I’m using next.js on the frontend if this is of help.

Answer:

Had the exact same problem. Studied the AWS docs and wrote the (signature v4) procedure myself. The below is based on

https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html

and works perfectly.

I’ve also reported this issue to boto3 peeps:
https://github.com/boto/boto3/issues/1644

Leave a Reply