etianen / django-s3-storage

Django Amazon S3 file storage.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

403 error with version 1.6.3 of boto3

adamyala opened this issue · comments

django version: 2.0.2
django-s3-storage version: 0.12.4
boto3 version: 1.6.3

Uploading a file then accessing the url results in a 403 error with the message:

The request signature we calculated does not match the signature you provided. Check your key and signing method.

Last version of boto3 I used that made django-s3-storage work was 1.5.2. This time version 1.6.3 autoinstalled as a dep and it threw the above error.

As always, thank you for such a wonderful module.

I sat down to recreate today and the problem went away. No idea why. Apologies for eating up some of your time.

If the issue comes back I'll reopen.

@etianen I'd like to reopen this issue and help debug the underlying cause. I have the latest boto3 version installed (1.9.27) and this bug reappeared. I downgraded to 1.5.2 per my note above to see if that would fix it, and it did fix it.

What information can I supply to start our research?

Below are my settings:

DEFAULT_FILE_STORAGE = 'django_s3_storage.storage.S3Storage'
STATICFILES_STORAGE = 'django_s3_storage.storage.StaticS3Storage'
# The AWS region to connect to.
AWS_REGION = 'us-west-2'
# The AWS access key to use.
AWS_ACCESS_KEY_ID = 'XXXX'
# The AWS secret access key to use.
AWS_SECRET_ACCESS_KEY = 'XXXX'
# The name of the bucket to store files in.
AWS_S3_BUCKET_NAME = AWS_S3_BUCKET_NAME_STATIC = 'XXXXX'

Note that this only seems to be failing locally (while developing on my laptop). When running on a server things seem fine.

I'm also getting a 403. Do I need to change the settings of the bucket or anything else?

The same thing was happening to me yesterday, but once i started to debug the issue today it seems to have vanished.
I did not change any packages in between.

boto3==1.9.127
Django==2.2
django-s3-storage==0.12.4

Same here. Pinning boto3 to 1.5.2 solved it immediately.

@etianen and others, I had this error until I found this boto/boto3#1644 (comment)

To get rid of this error, set the following settings:

AWS_S3_ADDRESSING_STYLE = 'path'

Now I successfully can view objects with boto3=1.14.45 and django-s3-storage="0.13.3"

@etianen do you think this should be changed to the default setting? I'm happy to open a PR. A better solution might be adjusting this based on the boto3 version, but I'm not sure if I will have time to make that PR

I struggled with lots of errors but finally managed to make it work (for generate_presigned_post).

I get my client from (if you need it)

client = S3Boto3Storage().bucket.meta.client

And those are the settings you need to experiment with

AWS_S3_SIGNATURE_VERSION = "s3v4"  # required for some regions
AWS_S3_ADDRESSING_STYLE = 'path'  # needed only in some cases, depending on your boto3 version
AWS_S3_REGION_NAME = ...  # might be necessary if your region is non-default
boto3==1.18.4
django-storages==1.11.1