1 """Config flow for Withings."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
9 from aiowithings
import AuthScope
16 from .const
import DEFAULT_TITLE, DOMAIN
20 config_entry_oauth2_flow.AbstractOAuth2FlowHandler, domain=DOMAIN
22 """Handle a config flow."""
29 return logging.getLogger(__name__)
33 """Extra data that needs to be appended to the authorize url."""
35 "scope": f
"{AuthScope.USER_INFO},{AuthScope.USER_METRICS},"
36 f
"{AuthScope.USER_ACTIVITY},{AuthScope.USER_SLEEP_EVENTS}"
40 self, entry_data: Mapping[str, Any]
41 ) -> ConfigFlowResult:
42 """Perform reauth upon an API authentication error."""
46 self, user_input: dict[str, Any] |
None =
None
47 ) -> ConfigFlowResult:
48 """Confirm reauth dialog."""
49 if user_input
is None:
50 return self.async_show_form(
51 step_id=
"reauth_confirm",
52 description_placeholders={CONF_NAME: self._get_reauth_entry().title},
54 return await self.async_step_user()
57 """Create an entry for the flow, or update existing entry."""
58 user_id =
str(data[CONF_TOKEN][
"userid"])
59 await self.async_set_unique_id(user_id)
60 if self.source != SOURCE_REAUTH:
61 self._abort_if_unique_id_configured()
63 return self.async_create_entry(
68 self._abort_if_unique_id_mismatch(reason=
"wrong_account")
69 return self.async_update_reload_and_abort(
70 self._get_reauth_entry(), data_updates=data
ConfigFlowResult async_oauth_create_entry(self, dict[str, Any] data)
dict[str, str] extra_authorize_data(self)
logging.Logger logger(self)
ConfigFlowResult async_step_reauth_confirm(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_reauth(self, Mapping[str, Any] entry_data)