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.
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.