1 """Config flow for yolink."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
12 from .const
import DOMAIN
16 config_entry_oauth2_flow.AbstractOAuth2FlowHandler, domain=DOMAIN
18 """Config flow to handle yolink OAuth2 authentication."""
25 return logging.getLogger(__name__)
29 """Extra data that needs to be appended to the authorize url."""
31 return {
"scope":
" ".join(scopes)}
34 self, entry_data: Mapping[str, Any]
35 ) -> ConfigFlowResult:
36 """Perform reauth upon an API authentication error."""
40 """Dialog that informs the user that reauth is required."""
41 if user_input
is None:
42 return self.async_show_form(step_id=
"reauth_confirm")
46 """Create an oauth config entry or update existing entry for reauth."""
47 if self.
sourcesource == SOURCE_REAUTH:
48 return self.async_update_reload_and_abort(
49 self._get_reauth_entry(), data_updates=data
51 return self.async_create_entry(title=
"YoLink", data=data)
54 self, user_input: dict[str, Any] |
None =
None
55 ) -> ConfigFlowResult:
56 """Handle a flow start."""
57 existing_entry = await self.async_set_unique_id(DOMAIN)
58 if existing_entry
and self.
sourcesource != SOURCE_REAUTH:
59 return self.async_abort(reason=
"already_configured")
ConfigFlowResult async_step_reauth(self, Mapping[str, Any] entry_data)
ConfigFlowResult async_step_reauth_confirm(self, user_input=None)
logging.Logger logger(self)
dict extra_authorize_data(self)
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_oauth_create_entry(self, dict data)