From 1805d9376c9a6fac86c113db4398aab2d955636b Mon Sep 17 00:00:00 2001 From: ZHUO Qiang Date: Tue, 28 Nov 2017 16:35:04 +0800 Subject: [PATCH] update client to support auth_token support `auth_token` to fix #25 --- nats/io/client.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nats/io/client.py b/nats/io/client.py index 7adf8a9..38411d3 100644 --- a/nats/io/client.py +++ b/nats/io/client.py @@ -289,8 +289,13 @@ def connect_command(self): } if "auth_required" in self._server_info: if self._server_info["auth_required"] == True: - options["user"] = self._current_server.uri.username - options["pass"] = self._current_server.uri.password + # In case there is no password, then consider handle + # sending a token instead. + if self._current_server.uri.password is None: + options["auth_token"] = self._current_server.uri.username + else: + options["user"] = self._current_server.uri.username + options["pass"] = self._current_server.uri.password if self.options["name"] is not None: options["name"] = self.options["name"]