1
0
mirror of https://github.com/thingsboard/thingsboard-gateway synced 2025-10-26 22:31:42 +08:00

Added ability to use clientId/username/password to connect to the ThingsBoard instance

This commit is contained in:
zbeacon
2022-08-11 11:54:39 +03:00
parent e479d3afec
commit f7b2ab5811
3 changed files with 17 additions and 9 deletions

View File

@@ -42,14 +42,22 @@ class TBClient(threading.Thread):
self.__ca_cert = None
self.__private_key = None
self.__cert = None
self.__token = None
self.__client_id = ""
self.__username = None
self.__password = None
self.__is_connected = False
self.__stopped = False
self.__paused = False
self._last_cert_check_time = 0
if credentials.get("accessToken") is not None:
self.__token = str(credentials["accessToken"])
self.client = TBGatewayMqttClient(self.__host, self.__port, self.__token, self, quality_of_service=self.__default_quality_of_service)
self.__username = str(credentials["accessToken"])
if credentials.get("username") is not None:
self.__username = str(credentials["username"])
if credentials.get("password") is not None:
self.__password = str(credentials["password"])
if credentials.get("clientId") is not None:
self.__client_id = str(credentials["clientId"])
self.client = TBGatewayMqttClient(self.__host, self.__port, self.__username, self.__password, self, quality_of_service=self.__default_quality_of_service, client_id=self.__client_id)
if self.__tls:
self.__ca_cert = self.__config_folder_path + credentials.get("caCert") if credentials.get("caCert") is not None else None
self.__private_key = self.__config_folder_path + credentials.get("privateKey") if credentials.get("privateKey") is not None else None