2

I'm setting up a Django app on Heroku and want to store media files on S3. I'm using Python's Boto module and keep on running into the same error:

Error:

No handler was ready to authenticate. 
1 handlers were checked. ['HmacAuthV1Handler'] Check your credentials

I've tried saving my credentials

(a) in my Heroku config file and using os.environ['AWS_ACCESS_KEY_ID]

(b) in my settings.py file and

(c) in a separate .boto file as per the documentation.

Here is are the relevant parts of my settings.py, with the credentials in the file itself:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': "os.path.join(BASE_DIR, 'db.sqlite3')",   # Or path to database file if using sqlite3.
        # The following settings are not used with sqlite3:
        'USER': '',
        'PASSWORD': '',
        'HOST': '',                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
        'PORT': '',                      # Set to empty string for default.
    }
}

#config for S3
DATABASES['default'] =  dj_database_url.config()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

S3_BUCKET_NAME = 'companylistings'
#AWS_ACCESS_KEY_ID = 'xxxxxxxxxxxxxxx'
#AWS_SECRET_ACCESS_KEY = 'xxxxxxxxxxxxxxx'
#STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
S3_URL = 'http://s3.amazonaws.com/%s' %S3_BUCKET_NAME


MEDIA_ROOT = '/media/'
MEDIA_URL = S3_URL + MEDIA_ROOT

STATIC_ROOT = '/static/'
STATIC_URL = S3_URL + STATIC_ROOT

BASE_DIR = os.path.dirname(os.path.abspath(__file__))

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)
Glyn Jackson
  • 8,228
  • 4
  • 29
  • 52
Suraj Kapoor
  • 1,615
  • 4
  • 22
  • 34

2 Answers2

1

If it is on windows please follow this:

Install:pip install awscli

Open cmd and type:

$ aws configure
AWS Access Key ID: 'your Access Key ID'
AWS Secret Access Key: 'your Secret Access Key'
Default region name: us-east-1
Default output format: json

$ manage.py shell
>>import boto
>>s3 = boto.connect_s3()

no error message shown. it's done

Details: http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-quick-configuration

Md. Sabbir Ahamed
  • 435
  • 1
  • 6
  • 20
0

Check the bucket setting you have :

S3_BUCKET_NAME

my working configuration is :

AWS_STORAGE_BUCKET_NAME

Try this!

My full config is :

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_ACCESS_KEY_ID = 'PRIVATE'
AWS_SECRET_ACCESS_KEY = 'PRIVATE'
AWS_STORAGE_BUCKET_NAME = 'PRIVATE'
Belug
  • 71
  • 2