Please use AWS4-HMAC-SHA256 error in django-storages@1.4.1
Closed this issue ยท 10 comments
i am getting this error: The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.
I am using Django - 1.6.7, boto- 2.49.0
Try using this values in settings.py:
if using boto3
AWS_S3_REGION_NAME = 'us-east-2' #change to your region
AWS_S3_SIGNATURE_VERSION = 's3v4'
if using boto
AWS_S3_HOST = 'us-east-2' #change to your region
S3_USE_SIGV4 = True
@jschneier This is still an issue in the default setup
For anyone else who hits this, the way I'm solving it is by removing the signature information from the url:
url_with_signature = model_instance.my_image_field.url # Results in AWS error
good_url = url_with_signature[:url_with_signature.index('?')]
For anyone else who hits this, the way I'm solving it is by removing the signature information from the url:
url_with_signature = model_instance.my_image_field.url # Results in AWS error good_url = url_with_signature[:url_with_signature.index('?')]
A better way to not include signature in the url would be to use the AWS_QUERYSTRING_AUTH=False
.
@Mexarm 's fix worked for me, but isn't there a fix for storages to prevent the error from even happening? Why close the issue?
I'm getting "The request signature we calculated does not match the signature you provided. Check your key and signing method." with Mexarm's boto3 solution.
Try using this values in settings.py:
if using boto3
AWS_S3_REGION_NAME = 'us-east-2' #change to your region
AWS_S3_SIGNATURE_VERSION = 's3v4'if using boto
AWS_S3_HOST = 'us-east-2' #change to your region
S3_USE_SIGV4 = True
Thank you so much sir. Its worked.
I'm getting "The request signature we calculated does not match the signature you provided. Check your key and signing method." with Mexarm's boto3 solution.
getting the same error
@Mexarm's solution for boto3 worked for me. My region was 'ap-south-1'.
AWS_S3_REGION_NAME = 'ap-south-1' #change to your region
AWS_S3_SIGNATURE_VERSION = 's3v4'
Thank you so much.
AWS_S3_ACCESS_KEY_ID = config('AWS_S3_ACCESS_KEY_ID')
AWS_S3_SECRET_ACCESS_KEY = config('AWS_S3_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = config('AWS_STORAGE_BUCKET_NAME')
object_key = file_path
# Create an S3 client ap-south-1
s3 = boto3.client('s3', aws_access_key_id=AWS_S3_ACCESS_KEY_ID,
aws_secret_access_key=AWS_S3_SECRET_ACCESS_KEY, region_name='ap-south-1',
config=boto3.session.Config(signature_version='s3v4', s3={'signature_version': 's3v4', 'use_accelerate_endpoint': False}))
# Generate a pre-signed URL for GET operation (download)
url = s3.generate_presigned_url(
ClientMethod='get_object',
Params={'Bucket': AWS_STORAGE_BUCKET_NAME, 'Key': object_key},
ExpiresIn=3600 # URL will expire in 1 hour (3600 seconds)
)
This is how it solve the problem