From 925d84c669c32f1bddb599e24677d9b8e1ef9191 Mon Sep 17 00:00:00 2001 From: azerty9971 Date: Thu, 29 Aug 2024 15:02:16 +0200 Subject: [PATCH] Fix refreshing of the credentials in case the refresh token is expired If the call to refresh the access token fails because the token is expired then the result of the new connect (which is a new refresh token and a new access token) should be stored in the TuyaTokenInfo that is created in the __refresh_access_token_if_need (line 168). Without this code, the returned payload is the error one (code 1010) and is thus stored in the TuyaTokenInfo instead of the newly retrieved credentials. --- tuya_iot/openapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tuya_iot/openapi.py b/tuya_iot/openapi.py index 10e6f23..72b0503 100644 --- a/tuya_iot/openapi.py +++ b/tuya_iot/openapi.py @@ -281,7 +281,7 @@ def __request( if result.get("code", -1) == TUYA_ERROR_CODE_TOKEN_INVALID: self.token_info = None - self.connect( + return self.connect( self.__username, self.__password, self.__country_code, self.__schema )