AWS s3 boto3: Error when generating presigned URL The authorization mechanism you have provided is not supported

17 views Asked by At

I am trying to use the AWS Python SDK BOTO3 to generate a preseigned URL that will allow me to access a file. I keep getting this error

<Error>
    <Code>InvalidRequest</Code>
    <Message>The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.</Message>
    <RequestId>TCS5AKTVFTRPH8E8</RequestId>
    <HostId>Kji20SQmp7DM3hdanuW+8xXqDyDQ2U0i15yPwSjjVEOyOrpZBa1/AthiSNaGPUL0feqhunb3ZTo=</HostId>
</Error>

The presigned URL generation code is straight from the boto3 documentation at https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-presigned-urls.html

Things I have tried

- If I generate the URL from the AWS console on the browser, I can access all files
- I have tried generating from the shell, Postman, and Python script

None of the answers here work - The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256 - Amazon S3 : The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256

1

There are 1 answers

0
Ranai Srivastav On

After trying for over 2 weeks the problem was really simple

My credentials at ~/.aws has region set as us-east-1 which is true for almost every other AWS service I am using EXCEPT s3. I went into the credential file and changed the region to the region where my s3 bucket is located and the pre-signed URL worked.

I assume the reason the error was generated is because east1 and east2 were established on different dates and use different algorithms for safety (v2 vs v4) and thus, the error about this.