Question

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.

Était-ce utile?

La solution

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.

Autres conseils

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")
...
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top