Home Assistant Unofficial Reference 2024.12.1
config_flow.py
Go to the documentation of this file.
1 """Config flow for xbox."""
2 
3 import logging
4 from typing import Any
5 
6 from homeassistant.config_entries import ConfigFlowResult
7 from homeassistant.helpers import config_entry_oauth2_flow
8 
9 from .const import DOMAIN
10 
11 
13  config_entry_oauth2_flow.AbstractOAuth2FlowHandler, domain=DOMAIN
14 ):
15  """Config flow to handle xbox OAuth2 authentication."""
16 
17  DOMAIN = DOMAIN
18 
19  @property
20  def logger(self) -> logging.Logger:
21  """Return logger."""
22  return logging.getLogger(__name__)
23 
24  @property
25  def extra_authorize_data(self) -> dict:
26  """Extra data that needs to be appended to the authorize url."""
27  scopes = ["Xboxlive.signin", "Xboxlive.offline_access"]
28  return {"scope": " ".join(scopes)}
29 
30  async def async_step_user(
31  self, user_input: dict[str, Any] | None = None
32  ) -> ConfigFlowResult:
33  """Handle a flow start."""
34  await self.async_set_unique_id(DOMAIN)
35 
36  if self._async_current_entries():
37  return self.async_abort(reason="single_instance_allowed")
38 
39  return await super().async_step_user(user_input)
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
Definition: config_flow.py:32