mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Use new reauth helpers in youtube (#128835)
This commit is contained in:
parent
4fc872a4cb
commit
f9ce8fa368
@ -12,6 +12,7 @@ from youtubeaio.types import AuthScope, ForbiddenError
|
|||||||
from youtubeaio.youtube import YouTube
|
from youtubeaio.youtube import YouTube
|
||||||
|
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
|
SOURCE_REAUTH,
|
||||||
ConfigEntry,
|
ConfigEntry,
|
||||||
ConfigFlowResult,
|
ConfigFlowResult,
|
||||||
OptionsFlowWithConfigEntry,
|
OptionsFlowWithConfigEntry,
|
||||||
@ -45,7 +46,6 @@ class OAuth2FlowHandler(
|
|||||||
|
|
||||||
DOMAIN = DOMAIN
|
DOMAIN = DOMAIN
|
||||||
|
|
||||||
reauth_entry: ConfigEntry | None = None
|
|
||||||
_youtube: YouTube | None = None
|
_youtube: YouTube | None = None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -75,9 +75,6 @@ class OAuth2FlowHandler(
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Perform reauth upon an API authentication error."""
|
"""Perform reauth upon an API authentication error."""
|
||||||
self.reauth_entry = self.hass.config_entries.async_get_entry(
|
|
||||||
self.context["entry_id"]
|
|
||||||
)
|
|
||||||
return await self.async_step_reauth_confirm()
|
return await self.async_step_reauth_confirm()
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
@ -117,22 +114,19 @@ class OAuth2FlowHandler(
|
|||||||
self._title = own_channel.snippet.title
|
self._title = own_channel.snippet.title
|
||||||
self._data = data
|
self._data = data
|
||||||
|
|
||||||
if not self.reauth_entry:
|
await self.async_set_unique_id(own_channel.channel_id)
|
||||||
await self.async_set_unique_id(own_channel.channel_id)
|
if self.source != SOURCE_REAUTH:
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
|
|
||||||
return await self.async_step_channels()
|
return await self.async_step_channels()
|
||||||
|
|
||||||
if self.reauth_entry.unique_id == own_channel.channel_id:
|
self._abort_if_unique_id_mismatch(
|
||||||
self.hass.config_entries.async_update_entry(self.reauth_entry, data=data)
|
|
||||||
await self.hass.config_entries.async_reload(self.reauth_entry.entry_id)
|
|
||||||
return self.async_abort(reason="reauth_successful")
|
|
||||||
|
|
||||||
return self.async_abort(
|
|
||||||
reason="wrong_account",
|
reason="wrong_account",
|
||||||
description_placeholders={"title": self._title},
|
description_placeholders={"title": self._title},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return self.async_update_reload_and_abort(self._get_reauth_entry(), data=data)
|
||||||
|
|
||||||
async def async_step_channels(
|
async def async_step_channels(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user