From 4a2411fc78ee4325e659d7f974a8b8e330ee0b8e Mon Sep 17 00:00:00 2001 From: topsworld Date: Thu, 9 Jan 2025 22:24:48 +0800 Subject: [PATCH] fix: fix option flow oauth --- custom_components/xiaomi_home/config_flow.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/custom_components/xiaomi_home/config_flow.py b/custom_components/xiaomi_home/config_flow.py index 48845db..8e48849 100644 --- a/custom_components/xiaomi_home/config_flow.py +++ b/custom_components/xiaomi_home/config_flow.py @@ -1150,7 +1150,9 @@ class OptionsFlowHandler(config_entries.OptionsFlow): async def async_step_oauth(self, user_input=None): try: if self._cc_task_oauth is None: - state = str(secrets.randbits(64)) + state = hashlib.sha1( + f'd=ha.{self._entry_data["uuid"]}'.encode('utf-8') + ).hexdigest() self.hass.data[DOMAIN][self._virtual_did]['oauth_state'] = state self._miot_oauth.set_redirect_url( redirect_url=self._oauth_redirect_url_full)