redis-py icon indicating copy to clipboard operation
redis-py copied to clipboard

Authentication failure with v5.0

Open nwoods opened this issue 2 years ago • 3 comments

Version: redis-py 5.0.0, redis 5.0.7-2ubuntu0.1

Platform: Ubuntu 20.04

Description:

The following script works with redis-py 4.6.0 but throws redis.exceptions.AuthenticationError: Authentication required. with redis-py 5.0.0:

from redis import Redis

if __name__ == '__main__':
    redis = Redis(
        host='xxx',
        port=1234,
        ssl=True
    )
    redis.auth('xxx', 'xxx')
    if redis.ping():
        print('success')

(I obviously changed the host, port, username, and password).

This is using Ubuntu 20.04, and apt list shows the redis version as 5.0.7-2ubuntu0.1.

I'm not sufficiently knowledgeable to guess what information about the redis server would be useful, so please let me know.

Stack trace from v5.0:

Traceback (most recent call last):
  File "auth.py", line 10, in <module>
    redis.auth(password, username)
  File "/home/ubuntu/nate-temp/python_peripheral_tools-0.8.0/venv/lib/python3.8/site-packages/redis/commands/core.py", line 417, in auth
    return self.execute_command("AUTH", *pieces, **kwargs)
  File "/home/ubuntu/nate-temp/python_peripheral_tools-0.8.0/venv/lib/python3.8/site-packages/redis/client.py", line 505, in execute_command
    conn = self.connection or pool.get_connection(command_name, **options)
  File "/home/ubuntu/nate-temp/python_peripheral_tools-0.8.0/venv/lib/python3.8/site-packages/redis/connection.py", line 1073, in get_connection
    connection.connect()
  File "/home/ubuntu/nate-temp/python_peripheral_tools-0.8.0/venv/lib/python3.8/site-packages/redis/connection.py", line 271, in connect
    self.on_connect()
  File "/home/ubuntu/nate-temp/python_peripheral_tools-0.8.0/venv/lib/python3.8/site-packages/redis/connection.py", line 372, in on_connect
    self.read_response()
  File "/home/ubuntu/nate-temp/python_peripheral_tools-0.8.0/venv/lib/python3.8/site-packages/redis/connection.py", line 493, in read_response
    response = self._parser.read_response(disable_decoding=disable_decoding)
  File "/home/ubuntu/nate-temp/python_peripheral_tools-0.8.0/venv/lib/python3.8/site-packages/redis/_parsers/resp2.py", line 15, in read_response
    result = self._read_response(disable_decoding=disable_decoding)
  File "/home/ubuntu/nate-temp/python_peripheral_tools-0.8.0/venv/lib/python3.8/site-packages/redis/_parsers/resp2.py", line 38, in _read_response
    raise error
redis.exceptions.AuthenticationError: Authentication required.

nwoods avatar Aug 31 '23 21:08 nwoods

@dvora-h bump

chayim avatar Dec 19 '23 09:12 chayim

@nwoods Ideally you wouldn't authenticate this way. Auth should happen during the construction of redis.Redis, as username and password are supported there.

@dvora-h either way, please have a look

chayim avatar Dec 19 '23 10:12 chayim

This issue is marked stale. It will be closed in 30 days if it is not updated.

github-actions[bot] avatar Jun 26 '25 00:06 github-actions[bot]