1

I'm having a very strange issue.

I have my django project running in Heroku using S3 to store my static assets.

I wanted to use the Heroku enviroment variables by setting them as follows:

heroku config:add AWS_S3_TOKEN=my_s3_token
heroku config:add AWS_S3_SECRET=my_s3_secret

And using them with python's os module:

import os

token = os.getenv('AWS_S3_TOKEN')
secret = os.getenv('AWS_S3_SECRET')

But heroku keeps throwing me the following error:

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

So, I ended up writing those parameters in my settings.py file and it works fine

Why is this happening?

If I run

heroku config

I can see all my seted variables and if i do

heroku run python manage.py shell

and then

import os
print os.getenv('AWS_S3_TOKEN')

For example, it prints the variable's value.

any clue on this???

Thank you in advance

2 Answers 2

1

I'm not familiar with python or Django, but I'm curious.

If you try your authentication with blank strings, do you get the same error?

If so, then I suspect it's about when you're doing this authentication dance. When are you doing it? At compile time, or at runtime? (If at compile time, look at this)

Sign up to request clarification or add additional context in comments.

Comments

0

The app's environment variables aren't usually available while Heroku is compiling the slug and setting up the application, they're only available once the app is running. For a Django app, Heroku will run collectstatic as part of slug compilation, which is probably why you're seeing this error.

You can make the environment variables available during compilation by enabling a Heroku Labs feature:

heroku labs:enable user-env-compile

There's more information in this Heroku dev centre article: https://devcenter.heroku.com/articles/labs-user-env-compile

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.