0

How can I send "AUTH" command to authenticate the connection using Flask-Redis in Flask app? I know Flask-Redis is just a small wrapper for redis-py but I can't figure out how to handle the authorization.

2 Answers 2

5

Do you mean this Flask_Redis: https://pypi.python.org/pypi/Flask-Redis/0.0.5 ?

If so, there is a better way to handle this than placing it in the URL. According to the docs, in your Flask config place the following:

REDIS_HOST = "localhost"
REDIS_PASSWORD = "password"
REDIS_PORT = 6379

If placing the config in code, as in your example:

app.config["REDIS_PASSWORD"] = 'password'

Doing this in the config should be more maintainable and configurable without modifying code.

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

Comments

1

Ok I have found how to solve this. You can pass the password in URL, example:

...
app.config["REDIS_URL"] = 'redis://:password@localhost/0'
redis_db = Redis(app, "REDIS")
...

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.