Skip to content

Commit 6c20ccd

Browse files
committed
Fix AuthenticationClient for encrypted channels
The function generate_shared_secret expects the first argument "channel" in binary for Python 3, but it was passed as a string. That caused a `TypeError: can only concatenate str (not "bytes") to str` exception when using `authenticate` with encryption.
1 parent ba32489 commit 6c20ccd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pusher/authentication_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from pusher.util import (
1919
ensure_text,
20+
ensure_binary,
2021
validate_channel,
2122
validate_socket_id,
2223
channel_name_re
@@ -76,7 +77,8 @@ def authenticate(self, channel, socket_id, custom_data=None):
7677
response_payload = { "auth": auth }
7778

7879
if is_encrypted_channel(channel):
79-
shared_secret = generate_shared_secret(channel, self._encryption_master_key)
80+
shared_secret = generate_shared_secret(
81+
ensure_binary(channel, "channel"), self._encryption_master_key)
8082
shared_secret_b64 = base64.b64encode(shared_secret)
8183
response_payload["shared_secret"] = shared_secret_b64
8284

0 commit comments

Comments
 (0)