From f5f831df9330b5f031b3ef25f8fa631953b1d5ec Mon Sep 17 00:00:00 2001 From: Josef Zweck Date: Thu, 3 Sep 2026 08:16:46 +0200 Subject: [PATCH] Centrally handle ImplementationUnavailableError (#180253) --- .../components/aladdin_connect/__init__.py | 17 ++++------------- .../components/aladdin_connect/strings.json | 3 --- homeassistant/components/august/__init__.py | 6 +----- homeassistant/components/dropbox/__init__.py | 9 +-------- homeassistant/components/dropbox/strings.json | 3 --- homeassistant/components/fitbit/__init__.py | 19 +++++-------------- homeassistant/components/fitbit/strings.json | 5 ----- .../components/gentex_homelink/__init__.py | 16 +++++----------- .../components/gentex_homelink/strings.json | 5 ----- .../components/geocaching/__init__.py | 11 +---------- .../components/geocaching/strings.json | 5 ----- homeassistant/components/google/__init__.py | 17 ++++------------- homeassistant/components/google/strings.json | 5 ----- .../google_assistant_sdk/__init__.py | 9 +-------- .../google_assistant_sdk/strings.json | 3 --- .../components/google_drive/__init__.py | 9 +-------- .../components/google_drive/strings.json | 3 --- .../components/google_health/__init__.py | 11 ++--------- .../components/google_health/strings.json | 3 --- .../components/google_mail/__init__.py | 10 +--------- .../components/google_mail/strings.json | 3 --- .../components/google_photos/__init__.py | 14 ++++---------- .../components/google_photos/strings.json | 3 --- .../components/google_sheets/__init__.py | 9 +-------- .../components/google_sheets/strings.json | 3 --- .../components/google_tasks/__init__.py | 14 ++++---------- .../components/google_tasks/strings.json | 5 ----- .../components/home_connect/__init__.py | 9 +-------- .../components/home_connect/strings.json | 3 --- .../husqvarna_automower/__init__.py | 17 ++++------------- .../husqvarna_automower/strings.json | 3 --- homeassistant/components/iotty/__init__.py | 11 +---------- homeassistant/components/iotty/strings.json | 5 ----- homeassistant/components/lyric/__init__.py | 15 ++++----------- homeassistant/components/lyric/strings.json | 3 --- homeassistant/components/mcp/__init__.py | 9 +-------- homeassistant/components/mcp/strings.json | 5 ----- .../components/microbees/__init__.py | 16 +++++----------- .../components/microbees/strings.json | 5 ----- homeassistant/components/miele/__init__.py | 9 +-------- homeassistant/components/miele/strings.json | 3 --- homeassistant/components/monzo/__init__.py | 10 ++-------- homeassistant/components/monzo/strings.json | 3 --- homeassistant/components/myuplink/__init__.py | 9 +-------- .../components/myuplink/strings.json | 3 --- homeassistant/components/neato/__init__.py | 9 +-------- homeassistant/components/neato/strings.json | 5 ----- homeassistant/components/netatmo/__init__.py | 9 +-------- homeassistant/components/netatmo/strings.json | 3 --- .../components/ondilo_ico/__init__.py | 10 +--------- .../components/ondilo_ico/strings.json | 5 ----- homeassistant/components/onedrive/__init__.py | 9 +-------- .../components/onedrive/strings.json | 3 --- .../onedrive_for_business/__init__.py | 9 +-------- .../onedrive_for_business/strings.json | 3 --- homeassistant/components/point/__init__.py | 9 +-------- homeassistant/components/point/strings.json | 5 ----- homeassistant/components/senz/__init__.py | 9 +-------- homeassistant/components/senz/strings.json | 3 --- homeassistant/components/smappee/__init__.py | 15 ++++----------- homeassistant/components/smappee/strings.json | 5 ----- .../components/smartthings/__init__.py | 9 +-------- .../components/smartthings/strings.json | 3 --- homeassistant/components/spotify/__init__.py | 9 +-------- homeassistant/components/spotify/strings.json | 5 ----- .../components/tesla_fleet/__init__.py | 15 +-------------- .../components/tesla_fleet/strings.json | 3 --- .../components/teslemetry/__init__.py | 9 +-------- .../components/teslemetry/strings.json | 3 --- homeassistant/components/tibber/__init__.py | 9 +-------- homeassistant/components/tibber/strings.json | 3 --- homeassistant/components/toon/__init__.py | 10 +--------- homeassistant/components/toon/strings.json | 3 --- homeassistant/components/twitch/__init__.py | 17 +++++------------ homeassistant/components/twitch/strings.json | 5 ----- homeassistant/components/vicare/__init__.py | 18 ++++-------------- homeassistant/components/volvo/__init__.py | 9 +-------- homeassistant/components/volvo/strings.json | 3 --- homeassistant/components/watts/__init__.py | 14 ++++---------- homeassistant/components/watts/strings.json | 3 --- homeassistant/components/weheat/__init__.py | 11 ++--------- homeassistant/components/weheat/strings.json | 5 ----- homeassistant/components/withings/__init__.py | 10 +--------- .../components/withings/strings.json | 5 ----- homeassistant/components/xbox/__init__.py | 17 ++--------------- homeassistant/components/xbox/strings.json | 3 --- homeassistant/components/yale/__init__.py | 6 +----- homeassistant/components/yolink/__init__.py | 9 +-------- homeassistant/components/yolink/strings.json | 3 --- homeassistant/components/yoto/__init__.py | 9 +-------- homeassistant/components/yoto/strings.json | 3 --- homeassistant/components/youtube/__init__.py | 10 +--------- homeassistant/components/youtube/strings.json | 5 ----- .../integration/__init__.py | 9 +-------- tests/components/youtube/__init__.py | 2 +- tests/components/youtube/test_init.py | 3 +-- 96 files changed, 98 insertions(+), 631 deletions(-) diff --git a/homeassistant/components/aladdin_connect/__init__.py b/homeassistant/components/aladdin_connect/__init__.py index 1e5cf061a6bd..119227505074 100644 --- a/homeassistant/components/aladdin_connect/__init__.py +++ b/homeassistant/components/aladdin_connect/__init__.py @@ -16,9 +16,6 @@ from homeassistant.helpers import ( config_entry_oauth2_flow, device_registry as dr, ) -from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, -) from . import api from .const import CONFIG_FLOW_MINOR_VERSION, CONFIG_FLOW_VERSION, DOMAIN @@ -31,17 +28,11 @@ async def async_setup_entry( hass: HomeAssistant, entry: AladdinConnectConfigEntry ) -> bool: """Set up Aladdin Connect Genie from a config entry.""" - try: - implementation = ( - await config_entry_oauth2_flow.async_get_config_entry_implementation( - hass, entry - ) + implementation = ( + await config_entry_oauth2_flow.async_get_config_entry_implementation( + hass, entry ) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + ) session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation) diff --git a/homeassistant/components/aladdin_connect/strings.json b/homeassistant/components/aladdin_connect/strings.json index 6a77a7d7a527..be4e58edde14 100644 --- a/homeassistant/components/aladdin_connect/strings.json +++ b/homeassistant/components/aladdin_connect/strings.json @@ -29,9 +29,6 @@ "close_door_failed": { "message": "Failed to close the garage door" }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - }, "open_door_failed": { "message": "Failed to open the garage door" } diff --git a/homeassistant/components/august/__init__.py b/homeassistant/components/august/__init__.py index 27d7e71bf534..74328139c30a 100644 --- a/homeassistant/components/august/__init__.py +++ b/homeassistant/components/august/__init__.py @@ -19,7 +19,6 @@ from homeassistant.exceptions import ( ) from homeassistant.helpers import device_registry as dr, issue_registry as ir from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -40,10 +39,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: AugustConfigEntry) -> bo raise ConfigEntryAuthFailed("Migration to OAuth required") session = async_create_august_clientsession(hass) - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady("OAuth implementation not available") from err + implementation = await async_get_config_entry_implementation(hass, entry) oauth_session = OAuth2Session(hass, entry, implementation) august_gateway = AugustGateway(Path(hass.config.config_dir), session, oauth_session) try: diff --git a/homeassistant/components/dropbox/__init__.py b/homeassistant/components/dropbox/__init__.py index 315ece9cea0d..e6787d96fede 100644 --- a/homeassistant/components/dropbox/__init__.py +++ b/homeassistant/components/dropbox/__init__.py @@ -11,7 +11,6 @@ from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.helpers import aiohttp_client from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -24,13 +23,7 @@ type DropboxConfigEntry = ConfigEntry[DropboxAPIClient] async def async_setup_entry(hass: HomeAssistant, entry: DropboxConfigEntry) -> bool: """Set up Dropbox from a config entry.""" - try: - oauth2_implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + oauth2_implementation = await async_get_config_entry_implementation(hass, entry) token = entry.data["token"] if not set(token.get("scope", "").split()).issuperset(OAUTH2_SCOPES): diff --git a/homeassistant/components/dropbox/strings.json b/homeassistant/components/dropbox/strings.json index f8d2b3aa22de..ebe90c7e84fd 100644 --- a/homeassistant/components/dropbox/strings.json +++ b/homeassistant/components/dropbox/strings.json @@ -37,9 +37,6 @@ }, "missing_scopes": { "message": "[%key:component::dropbox::config::step::reauth_permissions::description%]" - }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" } } } diff --git a/homeassistant/components/fitbit/__init__.py b/homeassistant/components/fitbit/__init__.py index 6b4e1cadbf34..f2378797d8d2 100644 --- a/homeassistant/components/fitbit/__init__.py +++ b/homeassistant/components/fitbit/__init__.py @@ -4,12 +4,9 @@ from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.helpers import config_entry_oauth2_flow -from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, -) from . import api -from .const import DOMAIN, FitbitScope +from .const import FitbitScope from .coordinator import FitbitConfigEntry, FitbitData, FitbitDeviceCoordinator from .exceptions import FitbitApiException, FitbitAuthException from .model import config_from_entry_data @@ -19,17 +16,11 @@ PLATFORMS: list[Platform] = [Platform.SENSOR] async def async_setup_entry(hass: HomeAssistant, entry: FitbitConfigEntry) -> bool: """Set up fitbit from a config entry.""" - try: - implementation = ( - await config_entry_oauth2_flow.async_get_config_entry_implementation( - hass, entry - ) + implementation = ( + await config_entry_oauth2_flow.async_get_config_entry_implementation( + hass, entry ) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + ) session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation) fitbit_api = api.OAuthFitbitApi( hass, session, unit_system=entry.data.get("unit_system") diff --git a/homeassistant/components/fitbit/strings.json b/homeassistant/components/fitbit/strings.json index 2de3e8e0317c..ebe44522a9de 100644 --- a/homeassistant/components/fitbit/strings.json +++ b/homeassistant/components/fitbit/strings.json @@ -116,10 +116,5 @@ "name": "Water" } } - }, - "exceptions": { - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - } } } diff --git a/homeassistant/components/gentex_homelink/__init__.py b/homeassistant/components/gentex_homelink/__init__.py index f2b4da4d3963..5dbba5f0958c 100644 --- a/homeassistant/components/gentex_homelink/__init__.py +++ b/homeassistant/components/gentex_homelink/__init__.py @@ -5,7 +5,7 @@ from homelink.mqtt_provider import MQTTProvider from homeassistant.const import EVENT_HOMEASSISTANT_STOP, Platform from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady +from homeassistant.exceptions import ConfigEntryAuthFailed from homeassistant.helpers import aiohttp_client, config_entry_oauth2_flow from . import oauth2 @@ -27,17 +27,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: HomeLinkConfigEntry) -> hass, DOMAIN, auth_implementation ) - try: - implementation = ( - await config_entry_oauth2_flow.async_get_config_entry_implementation( - hass, entry - ) + implementation = ( + await config_entry_oauth2_flow.async_get_config_entry_implementation( + hass, entry ) - except config_entry_oauth2_flow.ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + ) session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation) authenticated_session = oauth2.AsyncConfigEntryAuth( diff --git a/homeassistant/components/gentex_homelink/strings.json b/homeassistant/components/gentex_homelink/strings.json index 73f96423e52a..e50bb3e633c0 100644 --- a/homeassistant/components/gentex_homelink/strings.json +++ b/homeassistant/components/gentex_homelink/strings.json @@ -41,10 +41,5 @@ } } } - }, - "exceptions": { - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - } } } diff --git a/homeassistant/components/geocaching/__init__.py b/homeassistant/components/geocaching/__init__.py index be9e3c29b93b..144249ac42fb 100644 --- a/homeassistant/components/geocaching/__init__.py +++ b/homeassistant/components/geocaching/__init__.py @@ -2,14 +2,11 @@ from homeassistant.const import Platform from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) -from .const import DOMAIN from .coordinator import GeocachingConfigEntry, GeocachingDataUpdateCoordinator PLATFORMS = [Platform.SENSOR] @@ -17,13 +14,7 @@ PLATFORMS = [Platform.SENSOR] async def async_setup_entry(hass: HomeAssistant, entry: GeocachingConfigEntry) -> bool: """Set up Geocaching from a config entry.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) oauth_session = OAuth2Session(hass, entry, implementation) coordinator = GeocachingDataUpdateCoordinator( diff --git a/homeassistant/components/geocaching/strings.json b/homeassistant/components/geocaching/strings.json index d19a64d5442b..95a6eb452984 100644 --- a/homeassistant/components/geocaching/strings.json +++ b/homeassistant/components/geocaching/strings.json @@ -58,10 +58,5 @@ "unit_of_measurement": "souvenirs" } } - }, - "exceptions": { - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - } } } diff --git a/homeassistant/components/google/__init__.py b/homeassistant/components/google/__init__.py index a2f4420e2d38..b08f0520c56d 100644 --- a/homeassistant/components/google/__init__.py +++ b/homeassistant/components/google/__init__.py @@ -28,9 +28,6 @@ from homeassistant.exceptions import ( ) from homeassistant.helpers import config_entry_oauth2_flow, config_validation as cv from homeassistant.helpers.aiohttp_client import async_get_clientsession -from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, -) from homeassistant.helpers.entity import generate_entity_id from .api import ApiAuthImpl, get_feature_access @@ -95,17 +92,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: GoogleConfigEntry) -> bo _LOGGER.error("Configuration error in %s: %s", YAML_DEVICES, str(err)) return False - try: - implementation = ( - await config_entry_oauth2_flow.async_get_config_entry_implementation( - hass, entry - ) + implementation = ( + await config_entry_oauth2_flow.async_get_config_entry_implementation( + hass, entry ) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + ) session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation) # Force a token refresh to fix a bug where tokens were persisted with # expires_in (relative time delta) and expires_at (absolute time) swapped. diff --git a/homeassistant/components/google/strings.json b/homeassistant/components/google/strings.json index 7e6a9a54cb55..1dea97c6552f 100644 --- a/homeassistant/components/google/strings.json +++ b/homeassistant/components/google/strings.json @@ -48,11 +48,6 @@ } } }, - "exceptions": { - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - } - }, "options": { "step": { "init": { diff --git a/homeassistant/components/google_assistant_sdk/__init__.py b/homeassistant/components/google_assistant_sdk/__init__.py index e46019670f00..3b394ed571c3 100644 --- a/homeassistant/components/google_assistant_sdk/__init__.py +++ b/homeassistant/components/google_assistant_sdk/__init__.py @@ -17,7 +17,6 @@ from homeassistant.exceptions import ( ) from homeassistant.helpers import config_validation as cv, discovery, intent from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -53,13 +52,7 @@ async def async_setup_entry( hass: HomeAssistant, entry: GoogleAssistantSDKConfigEntry ) -> bool: """Set up Google Assistant SDK from a config entry.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) try: await session.async_ensure_token_valid() diff --git a/homeassistant/components/google_assistant_sdk/strings.json b/homeassistant/components/google_assistant_sdk/strings.json index 74ad4a309317..1a25fc252a1e 100644 --- a/homeassistant/components/google_assistant_sdk/strings.json +++ b/homeassistant/components/google_assistant_sdk/strings.json @@ -39,9 +39,6 @@ "grpc_error": { "message": "Failed to communicate with Google Assistant" }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - }, "reauth_required": { "message": "Credentials are invalid, re-authentication required" } diff --git a/homeassistant/components/google_drive/__init__.py b/homeassistant/components/google_drive/__init__.py index 9a2bf25c83b1..0a0d9b99e924 100644 --- a/homeassistant/components/google_drive/__init__.py +++ b/homeassistant/components/google_drive/__init__.py @@ -10,7 +10,6 @@ from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import instance_id from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -29,13 +28,7 @@ _PLATFORMS = (Platform.SENSOR,) async def async_setup_entry(hass: HomeAssistant, entry: GoogleDriveConfigEntry) -> bool: """Set up Google Drive from a config entry.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) auth = AsyncConfigEntryAuth( async_get_clientsession(hass), diff --git a/homeassistant/components/google_drive/strings.json b/homeassistant/components/google_drive/strings.json index 9d26655ee2db..22766f86f7c8 100644 --- a/homeassistant/components/google_drive/strings.json +++ b/homeassistant/components/google_drive/strings.json @@ -67,9 +67,6 @@ }, "invalid_response_google_drive_error": { "message": "Invalid response from Google Drive: {error}" - }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" } } } diff --git a/homeassistant/components/google_health/__init__.py b/homeassistant/components/google_health/__init__.py index 8001ac637e0d..8fdff1e55277 100644 --- a/homeassistant/components/google_health/__init__.py +++ b/homeassistant/components/google_health/__init__.py @@ -10,10 +10,9 @@ from google_health_api.const import HealthApiScope from homeassistant.config_entries import ConfigEntry from homeassistant.const import Platform from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady +from homeassistant.exceptions import ConfigEntryAuthFailed from homeassistant.helpers import aiohttp_client, device_registry as dr from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -50,13 +49,7 @@ async def async_setup_entry( hass: HomeAssistant, entry: GoogleHealthConfigEntry ) -> bool: """Set up Google Health from a config entry.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth_error", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) diff --git a/homeassistant/components/google_health/strings.json b/homeassistant/components/google_health/strings.json index 636be3889051..9e19fd7b8c8e 100644 --- a/homeassistant/components/google_health/strings.json +++ b/homeassistant/components/google_health/strings.json @@ -83,9 +83,6 @@ }, "missing_profile_scope": { "message": "Missing required Google Health profile read permission." - }, - "oauth_error": { - "message": "OAuth2 implementation temporarily unavailable." } } } diff --git a/homeassistant/components/google_mail/__init__.py b/homeassistant/components/google_mail/__init__.py index 74d8e222e09f..79ffa5d184d5 100644 --- a/homeassistant/components/google_mail/__init__.py +++ b/homeassistant/components/google_mail/__init__.py @@ -3,10 +3,8 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_NAME, Platform from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import config_validation as cv, discovery from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -34,13 +32,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: GoogleMailConfigEntry) -> bool: """Set up Google Mail from a config entry.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) auth = AsyncConfigEntryAuth(hass, session) await auth.check_and_refresh_token() diff --git a/homeassistant/components/google_mail/strings.json b/homeassistant/components/google_mail/strings.json index 90ec90d81edc..548a3920b3ed 100644 --- a/homeassistant/components/google_mail/strings.json +++ b/homeassistant/components/google_mail/strings.json @@ -42,9 +42,6 @@ "exceptions": { "missing_from_for_alias": { "message": "Missing 'from' email when setting an alias to show. You have to provide a 'from' email" - }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" } }, "services": { diff --git a/homeassistant/components/google_photos/__init__.py b/homeassistant/components/google_photos/__init__.py index 69bc38db0365..dd2095c694e2 100644 --- a/homeassistant/components/google_photos/__init__.py +++ b/homeassistant/components/google_photos/__init__.py @@ -36,17 +36,11 @@ async def async_setup_entry( hass: HomeAssistant, entry: GooglePhotosConfigEntry ) -> bool: """Set up Google Photos from a config entry.""" - try: - implementation = ( - await config_entry_oauth2_flow.async_get_config_entry_implementation( - hass, entry - ) + implementation = ( + await config_entry_oauth2_flow.async_get_config_entry_implementation( + hass, entry ) - except config_entry_oauth2_flow.ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + ) web_session = async_get_clientsession(hass) oauth_session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation) diff --git a/homeassistant/components/google_photos/strings.json b/homeassistant/components/google_photos/strings.json index dab54f1fd717..838434c00555 100644 --- a/homeassistant/components/google_photos/strings.json +++ b/homeassistant/components/google_photos/strings.json @@ -59,9 +59,6 @@ "no_access_to_path": { "message": "Cannot read {filename}, no access to path; `allowlist_external_dirs` may need to be adjusted in `configuration.yaml`" }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - }, "upload_error": { "message": "Failed to upload content: {message}" } diff --git a/homeassistant/components/google_sheets/__init__.py b/homeassistant/components/google_sheets/__init__.py index 49c9a2b7d849..869a329afd00 100644 --- a/homeassistant/components/google_sheets/__init__.py +++ b/homeassistant/components/google_sheets/__init__.py @@ -13,7 +13,6 @@ from homeassistant.exceptions import ( ) from homeassistant.helpers import config_validation as cv from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -39,13 +38,7 @@ async def async_setup_entry( hass: HomeAssistant, entry: GoogleSheetsConfigEntry ) -> bool: """Set up Google Sheets from a config entry.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) try: await session.async_ensure_token_valid() diff --git a/homeassistant/components/google_sheets/strings.json b/homeassistant/components/google_sheets/strings.json index 74d668fae2dc..16f5072f6750 100644 --- a/homeassistant/components/google_sheets/strings.json +++ b/homeassistant/components/google_sheets/strings.json @@ -39,9 +39,6 @@ }, "get_failed": { "message": "Failed to retrieve data from the Google Sheets document" - }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" } }, "services": { diff --git a/homeassistant/components/google_tasks/__init__.py b/homeassistant/components/google_tasks/__init__.py index a8a30c89372f..cb0f1038c33b 100644 --- a/homeassistant/components/google_tasks/__init__.py +++ b/homeassistant/components/google_tasks/__init__.py @@ -28,17 +28,11 @@ PLATFORMS: list[Platform] = [Platform.TODO] async def async_setup_entry(hass: HomeAssistant, entry: GoogleTasksConfigEntry) -> bool: """Set up Google Tasks from a config entry.""" - try: - implementation = ( - await config_entry_oauth2_flow.async_get_config_entry_implementation( - hass, entry - ) + implementation = ( + await config_entry_oauth2_flow.async_get_config_entry_implementation( + hass, entry ) - except config_entry_oauth2_flow.ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + ) session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation) auth = api.AsyncConfigEntryAuth(hass, session) try: diff --git a/homeassistant/components/google_tasks/strings.json b/homeassistant/components/google_tasks/strings.json index 37e47381821b..5b69344a6e60 100644 --- a/homeassistant/components/google_tasks/strings.json +++ b/homeassistant/components/google_tasks/strings.json @@ -33,10 +33,5 @@ "title": "[%key:common::config_flow::title::reauth%]" } } - }, - "exceptions": { - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - } } } diff --git a/homeassistant/components/home_connect/__init__.py b/homeassistant/components/home_connect/__init__.py index c65e96298e01..414ceac9aedf 100644 --- a/homeassistant/components/home_connect/__init__.py +++ b/homeassistant/components/home_connect/__init__.py @@ -22,7 +22,6 @@ from homeassistant.helpers import ( issue_registry as ir, ) from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -59,13 +58,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: HomeConnectConfigEntry) -> bool: """Set up Home Connect from a config entry.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) diff --git a/homeassistant/components/home_connect/strings.json b/homeassistant/components/home_connect/strings.json index a6d266a9a1ec..8dc1aed4cb6e 100644 --- a/homeassistant/components/home_connect/strings.json +++ b/homeassistant/components/home_connect/strings.json @@ -1589,9 +1589,6 @@ "no_program_to_start": { "message": "No program to start" }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - }, "pause_program": { "message": "Error pausing program: {error}" }, diff --git a/homeassistant/components/husqvarna_automower/__init__.py b/homeassistant/components/husqvarna_automower/__init__.py index 84df0a5b14b5..6994867f275c 100644 --- a/homeassistant/components/husqvarna_automower/__init__.py +++ b/homeassistant/components/husqvarna_automower/__init__.py @@ -15,9 +15,6 @@ from homeassistant.helpers import ( config_entry_oauth2_flow, config_validation as cv, ) -from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, -) from homeassistant.helpers.typing import ConfigType from homeassistant.util import dt as dt_util @@ -49,17 +46,11 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: AutomowerConfigEntry) -> bool: """Set up this integration using UI.""" - try: - implementation = ( - await config_entry_oauth2_flow.async_get_config_entry_implementation( - hass, entry - ) + implementation = ( + await config_entry_oauth2_flow.async_get_config_entry_implementation( + hass, entry ) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + ) session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation) api_api = api.AsyncConfigEntryAuth( aiohttp_client.async_get_clientsession(hass), diff --git a/homeassistant/components/husqvarna_automower/strings.json b/homeassistant/components/husqvarna_automower/strings.json index 5674a4f8a5c0..86514dd7151d 100644 --- a/homeassistant/components/husqvarna_automower/strings.json +++ b/homeassistant/components/husqvarna_automower/strings.json @@ -482,9 +482,6 @@ "command_send_failed": { "message": "Failed to send command: {exception}" }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - }, "work_area_not_existing": { "message": "The selected work area does not exist." }, diff --git a/homeassistant/components/iotty/__init__.py b/homeassistant/components/iotty/__init__.py index cc7a0867264e..2565e0c89af3 100644 --- a/homeassistant/components/iotty/__init__.py +++ b/homeassistant/components/iotty/__init__.py @@ -4,14 +4,11 @@ import logging from homeassistant.const import Platform from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) -from .const import DOMAIN from .coordinator import ( IottyConfigEntry, IottyConfigEntryData, @@ -27,13 +24,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: IottyConfigEntry) -> boo """Set up iotty from a config entry.""" _LOGGER.debug("async_setup_entry entry_id=%s", entry.entry_id) - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) data_update_coordinator = IottyDataUpdateCoordinator(hass, entry, session) diff --git a/homeassistant/components/iotty/strings.json b/homeassistant/components/iotty/strings.json index c71c7bb761f9..5ae8b1aca12b 100644 --- a/homeassistant/components/iotty/strings.json +++ b/homeassistant/components/iotty/strings.json @@ -19,10 +19,5 @@ "title": "[%key:common::config_flow::title::oauth2_pick_implementation%]" } } - }, - "exceptions": { - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - } } } diff --git a/homeassistant/components/lyric/__init__.py b/homeassistant/components/lyric/__init__.py index 6a9a375f8c5d..92ee401f58c5 100644 --- a/homeassistant/components/lyric/__init__.py +++ b/homeassistant/components/lyric/__init__.py @@ -4,7 +4,6 @@ from aiolyric import Lyric from homeassistant.const import Platform from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import ( aiohttp_client, config_entry_oauth2_flow, @@ -28,17 +27,11 @@ PLATFORMS = [Platform.BINARY_SENSOR, Platform.CLIMATE, Platform.SELECT, Platform async def async_setup_entry(hass: HomeAssistant, entry: LyricConfigEntry) -> bool: """Set up Honeywell Lyric from a config entry.""" - try: - implementation = ( - await config_entry_oauth2_flow.async_get_config_entry_implementation( - hass, entry - ) + implementation = ( + await config_entry_oauth2_flow.async_get_config_entry_implementation( + hass, entry ) - except config_entry_oauth2_flow.ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + ) if not isinstance(implementation, LyricLocalOAuth2Implementation): raise TypeError("Unexpected auth implementation; can't find oauth client id") diff --git a/homeassistant/components/lyric/strings.json b/homeassistant/components/lyric/strings.json index 595ba439e7ad..acb780a3878d 100644 --- a/homeassistant/components/lyric/strings.json +++ b/homeassistant/components/lyric/strings.json @@ -104,9 +104,6 @@ }, "invalid_fan_mode": { "message": "The fan mode {fan_mode} is not supported by this device" - }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" } }, "services": { diff --git a/homeassistant/components/mcp/__init__.py b/homeassistant/components/mcp/__init__.py index 573bb7bd7583..d9c05e970d77 100644 --- a/homeassistant/components/mcp/__init__.py +++ b/homeassistant/components/mcp/__init__.py @@ -6,7 +6,6 @@ from typing import cast, override from homeassistant.components.application_credentials import AuthorizationServer from homeassistant.const import CONF_ACCESS_TOKEN from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import config_entry_oauth2_flow, llm from .application_credentials import authorization_server_context @@ -45,13 +44,7 @@ async def _create_token_manager( Returns None if the server does not require authentication. """ - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except config_entry_oauth2_flow.ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) if not implementation: return None diff --git a/homeassistant/components/mcp/strings.json b/homeassistant/components/mcp/strings.json index f4a2229fd508..f35618009143 100644 --- a/homeassistant/components/mcp/strings.json +++ b/homeassistant/components/mcp/strings.json @@ -52,10 +52,5 @@ } } } - }, - "exceptions": { - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - } } } diff --git a/homeassistant/components/microbees/__init__.py b/homeassistant/components/microbees/__init__.py index f0a39dc0352b..af5d4aa32c78 100644 --- a/homeassistant/components/microbees/__init__.py +++ b/homeassistant/components/microbees/__init__.py @@ -13,7 +13,7 @@ from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.helpers import config_entry_oauth2_flow -from .const import DOMAIN, PLATFORMS +from .const import PLATFORMS from .coordinator import MicroBeesUpdateCoordinator _LOGGER = logging.getLogger(__name__) @@ -50,17 +50,11 @@ async def async_migrate_entry(hass: HomeAssistant, entry: MicroBeesConfigEntry) async def async_setup_entry(hass: HomeAssistant, entry: MicroBeesConfigEntry) -> bool: """Set up microBees from a config entry.""" - try: - implementation = ( - await config_entry_oauth2_flow.async_get_config_entry_implementation( - hass, entry - ) + implementation = ( + await config_entry_oauth2_flow.async_get_config_entry_implementation( + hass, entry ) - except config_entry_oauth2_flow.ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + ) session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation) try: diff --git a/homeassistant/components/microbees/strings.json b/homeassistant/components/microbees/strings.json index 174624bf0ef8..bbe0922f8512 100644 --- a/homeassistant/components/microbees/strings.json +++ b/homeassistant/components/microbees/strings.json @@ -27,10 +27,5 @@ "title": "[%key:common::config_flow::title::oauth2_pick_implementation%]" } } - }, - "exceptions": { - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - } } } diff --git a/homeassistant/components/miele/__init__.py b/homeassistant/components/miele/__init__.py index e2740308f655..d4c4cff0028a 100644 --- a/homeassistant/components/miele/__init__.py +++ b/homeassistant/components/miele/__init__.py @@ -14,7 +14,6 @@ from homeassistant.exceptions import ( from homeassistant.helpers import config_validation as cv, device_registry as dr from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -54,13 +53,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: MieleConfigEntry) -> bool: """Set up Miele from a config entry.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) auth = AsyncConfigEntryAuth(async_get_clientsession(hass), session) diff --git a/homeassistant/components/miele/strings.json b/homeassistant/components/miele/strings.json index 33235a7b7979..81697d5cc7e0 100644 --- a/homeassistant/components/miele/strings.json +++ b/homeassistant/components/miele/strings.json @@ -1163,9 +1163,6 @@ "invalid_target": { "message": "Invalid device targeted." }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - }, "set_program_error": { "message": "'Set program' action failed: {status} / {message}" }, diff --git a/homeassistant/components/monzo/__init__.py b/homeassistant/components/monzo/__init__.py index 4cd36170f033..28377e3f3e18 100644 --- a/homeassistant/components/monzo/__init__.py +++ b/homeassistant/components/monzo/__init__.py @@ -10,7 +10,7 @@ from homeassistant.components import cloud from homeassistant.components.webhook import async_generate_id from homeassistant.const import CONF_ACCESS_TOKEN, CONF_WEBHOOK_ID, Platform from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ConfigEntryNotReady, OAuth2TokenRequestError +from homeassistant.exceptions import OAuth2TokenRequestError from homeassistant.helpers import config_validation as cv from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.config_entry_oauth2_flow import ( @@ -95,13 +95,7 @@ async def async_migrate_entry(hass: HomeAssistant, entry: MonzoConfigEntry) -> b async def async_setup_entry(hass: HomeAssistant, entry: MonzoConfigEntry) -> bool: """Set up Monzo from a config entry.""" - try: - external_api = await _async_create_api(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + external_api = await _async_create_api(hass, entry) coordinator = MonzoCoordinator(hass, entry, external_api) diff --git a/homeassistant/components/monzo/strings.json b/homeassistant/components/monzo/strings.json index b6630075c2cc..8fb9ed2109dc 100644 --- a/homeassistant/components/monzo/strings.json +++ b/homeassistant/components/monzo/strings.json @@ -88,9 +88,6 @@ "invalid_transfer_account": { "message": "{device_name} does not support pot transfers. Choose a different Monzo account." }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - }, "pot_account_mismatch": { "message": "{pot_name} belongs to {pot_account_name}, not {account_name}. Choose its associated Monzo account, or choose a pot belonging to {account_name}." }, diff --git a/homeassistant/components/myuplink/__init__.py b/homeassistant/components/myuplink/__init__.py index 7eac3776ce1d..5c057dbd751d 100644 --- a/homeassistant/components/myuplink/__init__.py +++ b/homeassistant/components/myuplink/__init__.py @@ -13,7 +13,6 @@ from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.helpers import device_registry as dr from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -40,13 +39,7 @@ async def async_setup_entry( ) -> bool: """Set up myUplink from a config entry.""" - try: - implementation = await async_get_config_entry_implementation(hass, config_entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, config_entry) session = OAuth2Session(hass, config_entry, implementation) auth = AsyncConfigEntryAuth(async_get_clientsession(hass), session) diff --git a/homeassistant/components/myuplink/strings.json b/homeassistant/components/myuplink/strings.json index 42db3b9d02a2..7c370f0e56d0 100644 --- a/homeassistant/components/myuplink/strings.json +++ b/homeassistant/components/myuplink/strings.json @@ -49,9 +49,6 @@ "config_entry_not_ready": { "message": "Error while loading the integration." }, - "implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - }, "incorrect_oauth2_scope": { "message": "Stored permissions are invalid. Please login again to update permissions." }, diff --git a/homeassistant/components/neato/__init__.py b/homeassistant/components/neato/__init__.py index 9ba9164bdbea..77a5759be2f7 100644 --- a/homeassistant/components/neato/__init__.py +++ b/homeassistant/components/neato/__init__.py @@ -17,7 +17,6 @@ from homeassistant.exceptions import ( ) from homeassistant.helpers import config_validation as cv from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -53,13 +52,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: NeatoConfigEntry) -> boo if CONF_TOKEN not in entry.data: raise ConfigEntryAuthFailed - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) try: diff --git a/homeassistant/components/neato/strings.json b/homeassistant/components/neato/strings.json index 0c9ff2126200..4dd4c2507feb 100644 --- a/homeassistant/components/neato/strings.json +++ b/homeassistant/components/neato/strings.json @@ -40,11 +40,6 @@ } } }, - "exceptions": { - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - } - }, "services": { "custom_cleaning": { "description": "Starts a custom cleaning of your house.", diff --git a/homeassistant/components/netatmo/__init__.py b/homeassistant/components/netatmo/__init__.py index 7f073a773bee..603935a618d2 100644 --- a/homeassistant/components/netatmo/__init__.py +++ b/homeassistant/components/netatmo/__init__.py @@ -22,7 +22,6 @@ from homeassistant.helpers import ( device_registry as dr, ) from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -54,13 +53,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: NetatmoConfigEntry) -> bool: """Set up Netatmo from a config entry.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) # Set unique id if non was set (migration) if not entry.unique_id: diff --git a/homeassistant/components/netatmo/strings.json b/homeassistant/components/netatmo/strings.json index 2d524b480069..2cf34d7e1ee0 100644 --- a/homeassistant/components/netatmo/strings.json +++ b/homeassistant/components/netatmo/strings.json @@ -156,9 +156,6 @@ "exceptions": { "entry_not_loaded": { "message": "The Netatmo integration is not loaded. Please set it up before calling this action." - }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" } }, "issues": { diff --git a/homeassistant/components/ondilo_ico/__init__.py b/homeassistant/components/ondilo_ico/__init__.py index 12a856d7360b..6c5f4d529b86 100644 --- a/homeassistant/components/ondilo_ico/__init__.py +++ b/homeassistant/components/ondilo_ico/__init__.py @@ -6,10 +6,8 @@ from homeassistant.components.application_credentials import ( ) from homeassistant.const import Platform from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import config_validation as cv from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, async_get_config_entry_implementation, ) from homeassistant.helpers.typing import ConfigType @@ -36,13 +34,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: OndiloIcoConfigEntry) -> bool: """Set up Ondilo ICO from a config entry.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) coordinator = OndiloIcoPoolsCoordinator( hass, entry, OndiloClient(hass, entry, implementation) diff --git a/homeassistant/components/ondilo_ico/strings.json b/homeassistant/components/ondilo_ico/strings.json index 003ef61bc62f..a7415ebd90ea 100644 --- a/homeassistant/components/ondilo_ico/strings.json +++ b/homeassistant/components/ondilo_ico/strings.json @@ -33,10 +33,5 @@ "name": "TDS" } } - }, - "exceptions": { - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - } } } diff --git a/homeassistant/components/onedrive/__init__.py b/homeassistant/components/onedrive/__init__.py index b998f5f2ce72..3428df1512cf 100644 --- a/homeassistant/components/onedrive/__init__.py +++ b/homeassistant/components/onedrive/__init__.py @@ -24,7 +24,6 @@ from homeassistant.exceptions import ( from homeassistant.helpers import config_validation as cv from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -171,13 +170,7 @@ async def _get_onedrive_client( hass: HomeAssistant, entry: OneDriveConfigEntry ) -> tuple[OneDriveClient, Callable[[], Awaitable[str]]]: """Get OneDrive client.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) # Refresh up front, so a failure surfaces here instead of from inside the client diff --git a/homeassistant/components/onedrive/strings.json b/homeassistant/components/onedrive/strings.json index 8d889da14c15..34b098741455 100644 --- a/homeassistant/components/onedrive/strings.json +++ b/homeassistant/components/onedrive/strings.json @@ -112,9 +112,6 @@ "no_files_match_pattern": { "message": "No files match the following patterns: {patterns}" }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - }, "update_failed": { "message": "Failed to update drive state" }, diff --git a/homeassistant/components/onedrive_for_business/__init__.py b/homeassistant/components/onedrive_for_business/__init__.py index 6f36120c8737..7ba0281f0705 100644 --- a/homeassistant/components/onedrive_for_business/__init__.py +++ b/homeassistant/components/onedrive_for_business/__init__.py @@ -21,7 +21,6 @@ from homeassistant.exceptions import ( ) from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -96,13 +95,7 @@ async def _get_onedrive_client( ) -> tuple[OneDriveClient, Callable[[], Awaitable[str]]]: """Get OneDrive client.""" with tenant_id_context(entry.data[CONF_TENANT_ID]): - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) # Refresh up front, so a failure surfaces here instead of from inside the client diff --git a/homeassistant/components/onedrive_for_business/strings.json b/homeassistant/components/onedrive_for_business/strings.json index 06ea2ceb26d0..dc63e62a9830 100644 --- a/homeassistant/components/onedrive_for_business/strings.json +++ b/homeassistant/components/onedrive_for_business/strings.json @@ -94,9 +94,6 @@ "failed_to_get_folder": { "message": "[%key:component::onedrive::exceptions::failed_to_get_folder::message%]" }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - }, "update_failed": { "message": "[%key:component::onedrive::exceptions::update_failed::message%]" } diff --git a/homeassistant/components/point/__init__.py b/homeassistant/components/point/__init__.py index a670f04de403..3771e26f59ee 100644 --- a/homeassistant/components/point/__init__.py +++ b/homeassistant/components/point/__init__.py @@ -12,7 +12,6 @@ from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.helpers import aiohttp_client from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -33,13 +32,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: PointConfigEntry) -> boo if "auth_implementation" not in entry.data: raise ConfigEntryAuthFailed("Authentication failed. Please re-authenticate.") - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) auth = api.AsyncConfigEntryAuth( aiohttp_client.async_get_clientsession(hass), session diff --git a/homeassistant/components/point/strings.json b/homeassistant/components/point/strings.json index 26463e82c4b0..9635c32d7c20 100644 --- a/homeassistant/components/point/strings.json +++ b/homeassistant/components/point/strings.json @@ -26,10 +26,5 @@ "title": "[%key:common::config_flow::title::reauth%]" } } - }, - "exceptions": { - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - } } } diff --git a/homeassistant/components/senz/__init__.py b/homeassistant/components/senz/__init__.py index d3ab6503b3ee..42747b6cf3cd 100644 --- a/homeassistant/components/senz/__init__.py +++ b/homeassistant/components/senz/__init__.py @@ -13,7 +13,6 @@ from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.helpers import config_validation as cv, httpx_client from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -31,13 +30,7 @@ PLATFORMS = [Platform.CLIMATE, Platform.SENSOR] async def async_setup_entry(hass: HomeAssistant, entry: SENZConfigEntry) -> bool: """Set up SENZ from a config entry.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) auth = SENZConfigEntryAuth(httpx_client.get_async_client(hass), session) senz_api = SENZAPI(auth) diff --git a/homeassistant/components/senz/strings.json b/homeassistant/components/senz/strings.json index 35564e0e156f..47600a4ebe37 100644 --- a/homeassistant/components/senz/strings.json +++ b/homeassistant/components/senz/strings.json @@ -34,9 +34,6 @@ "config_entry_not_ready": { "message": "Error while loading the integration." }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - }, "set_attribute_error": { "message": "Failed to set {attribute} on the device." } diff --git a/homeassistant/components/smappee/__init__.py b/homeassistant/components/smappee/__init__.py index 4289b9bd2f9e..3887a0babfd5 100644 --- a/homeassistant/components/smappee/__init__.py +++ b/homeassistant/components/smappee/__init__.py @@ -12,7 +12,6 @@ from homeassistant.const import ( CONF_PLATFORM, ) from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import config_entry_oauth2_flow, config_validation as cv from homeassistant.helpers.typing import ConfigType from homeassistant.util import Throttle @@ -96,17 +95,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: SmappeeConfigEntry) -> b ) await hass.async_add_executor_job(smappee.load_local_service_location) else: - try: - implementation = ( - await config_entry_oauth2_flow.async_get_config_entry_implementation( - hass, entry - ) + implementation = ( + await config_entry_oauth2_flow.async_get_config_entry_implementation( + hass, entry ) - except config_entry_oauth2_flow.ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + ) smappee_api = api.ConfigEntrySmappeeApi(hass, entry, implementation) diff --git a/homeassistant/components/smappee/strings.json b/homeassistant/components/smappee/strings.json index b6e952a3474e..d4197c78c40b 100644 --- a/homeassistant/components/smappee/strings.json +++ b/homeassistant/components/smappee/strings.json @@ -36,10 +36,5 @@ "title": "Discovered Smappee device" } } - }, - "exceptions": { - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - } } } diff --git a/homeassistant/components/smartthings/__init__.py b/homeassistant/components/smartthings/__init__.py index f7ad18bb531b..df3d8b0986a5 100644 --- a/homeassistant/components/smartthings/__init__.py +++ b/homeassistant/components/smartthings/__init__.py @@ -58,7 +58,6 @@ from homeassistant.exceptions import ( from homeassistant.helpers import device_registry as dr, entity_registry as er from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -134,13 +133,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: SmartThingsConfigEntry) # after migration but still require reauthentication if CONF_TOKEN not in entry.data: raise ConfigEntryAuthFailed("Config entry missing token") - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) try: diff --git a/homeassistant/components/smartthings/strings.json b/homeassistant/components/smartthings/strings.json index 7db88dcd85aa..8948c15fe17b 100644 --- a/homeassistant/components/smartthings/strings.json +++ b/homeassistant/components/smartthings/strings.json @@ -1146,9 +1146,6 @@ } }, "exceptions": { - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - }, "remote_control_status": { "message": "Can only be changed when remote control is enabled" } diff --git a/homeassistant/components/spotify/__init__.py b/homeassistant/components/spotify/__init__.py index 1f585730c959..7d11ab099687 100644 --- a/homeassistant/components/spotify/__init__.py +++ b/homeassistant/components/spotify/__init__.py @@ -10,7 +10,6 @@ from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -42,13 +41,7 @@ __all__ = [ async def async_setup_entry(hass: HomeAssistant, entry: SpotifyConfigEntry) -> bool: """Set up Spotify from a config entry.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) try: diff --git a/homeassistant/components/spotify/strings.json b/homeassistant/components/spotify/strings.json index 71493246e4cf..98ac05f0bddb 100644 --- a/homeassistant/components/spotify/strings.json +++ b/homeassistant/components/spotify/strings.json @@ -30,11 +30,6 @@ } } }, - "exceptions": { - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - } - }, "issues": { "user_not_premium": { "description": "[%key:component::spotify::config::abort::user_not_premium%]", diff --git a/homeassistant/components/tesla_fleet/__init__.py b/homeassistant/components/tesla_fleet/__init__.py index d450d1fd1669..be1b0ef2b39c 100644 --- a/homeassistant/components/tesla_fleet/__init__.py +++ b/homeassistant/components/tesla_fleet/__init__.py @@ -27,7 +27,6 @@ from homeassistant.exceptions import ( from homeassistant.helpers import config_validation as cv, device_registry as dr from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -108,19 +107,7 @@ async def _async_get_products(tesla: TeslaFleetApi) -> list[dict]: async def async_setup_entry(hass: HomeAssistant, entry: TeslaFleetConfigEntry) -> bool: """Set up TeslaFleet config.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err - except ValueError as e: - # Remove invalid implementation from config entry then raise AuthFailed - hass.config_entries.async_update_entry( - entry, data={"auth_implementation": None} - ) - raise ConfigEntryAuthFailed from e + implementation = await async_get_config_entry_implementation(hass, entry) oauth_session = OAuth2Session(hass, entry, implementation) try: diff --git a/homeassistant/components/tesla_fleet/strings.json b/homeassistant/components/tesla_fleet/strings.json index 5ef019db9eb9..b79f9f5129ec 100644 --- a/homeassistant/components/tesla_fleet/strings.json +++ b/homeassistant/components/tesla_fleet/strings.json @@ -636,9 +636,6 @@ "no_cable": { "message": "Charge cable will lock automatically when connected" }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - }, "update_failed": { "message": "{endpoint} data request failed: {message}" }, diff --git a/homeassistant/components/teslemetry/__init__.py b/homeassistant/components/teslemetry/__init__.py index f51bcb69d810..088f9dd79169 100644 --- a/homeassistant/components/teslemetry/__init__.py +++ b/homeassistant/components/teslemetry/__init__.py @@ -38,7 +38,6 @@ from homeassistant.helpers import ( ) from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -270,13 +269,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: TeslemetryConfigEntry) - translation_key="token_data_malformed", ) - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryAuthFailed( - translation_domain=DOMAIN, - translation_key="oauth_implementation_not_available", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) oauth_session = OAuth2Session(hass, entry, implementation) session = async_get_clientsession(hass) diff --git a/homeassistant/components/teslemetry/strings.json b/homeassistant/components/teslemetry/strings.json index d6392a764885..fa830604871d 100644 --- a/homeassistant/components/teslemetry/strings.json +++ b/homeassistant/components/teslemetry/strings.json @@ -1183,9 +1183,6 @@ "not_ready_connection_error": { "message": "Unable to connect to Teslemetry" }, - "oauth_implementation_not_available": { - "message": "OAuth implementation not available, try reauthenticating" - }, "set_scheduled_charging_time": { "message": "Scheduled charging time is required when enabling" }, diff --git a/homeassistant/components/tibber/__init__.py b/homeassistant/components/tibber/__init__.py index 5e49f4d0f827..750d20ceac9b 100644 --- a/homeassistant/components/tibber/__init__.py +++ b/homeassistant/components/tibber/__init__.py @@ -20,7 +20,6 @@ from homeassistant.exceptions import ( from homeassistant.helpers import config_validation as cv from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -114,13 +113,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: TibberConfigEntry) -> bo translation_key="data_api_reauth_required", ) - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) try: diff --git a/homeassistant/components/tibber/strings.json b/homeassistant/components/tibber/strings.json index 3f03653b2b3d..93abe359cb0d 100644 --- a/homeassistant/components/tibber/strings.json +++ b/homeassistant/components/tibber/strings.json @@ -249,9 +249,6 @@ "no_config_entry": { "message": "No Tibber integration configured" }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - }, "send_message_timeout": { "message": "Timeout sending message with Tibber" } diff --git a/homeassistant/components/toon/__init__.py b/homeassistant/components/toon/__init__.py index 212aa2e28bbe..6edfd2350516 100644 --- a/homeassistant/components/toon/__init__.py +++ b/homeassistant/components/toon/__init__.py @@ -11,10 +11,8 @@ from homeassistant.const import ( Platform, ) from homeassistant.core import CoreState, HomeAssistant -from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import config_validation as cv, device_registry as dr from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -96,13 +94,7 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ToonConfigEntry) -> bool: """Set up Toon from a config entry.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) coordinator = ToonDataUpdateCoordinator(hass, entry, session) diff --git a/homeassistant/components/toon/strings.json b/homeassistant/components/toon/strings.json index ea79172f024c..8fd0a1c6daeb 100644 --- a/homeassistant/components/toon/strings.json +++ b/homeassistant/components/toon/strings.json @@ -32,9 +32,6 @@ }, "invalid_response": { "message": "Received an invalid response from the Toon device." - }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" } } } diff --git a/homeassistant/components/twitch/__init__.py b/homeassistant/components/twitch/__init__.py index 862b7a8470cb..aeb15e979162 100644 --- a/homeassistant/components/twitch/__init__.py +++ b/homeassistant/components/twitch/__init__.py @@ -14,28 +14,21 @@ from homeassistant.exceptions import ( OAuth2TokenRequestReauthError, ) from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, LocalOAuth2Implementation, OAuth2Session, async_get_config_entry_implementation, ) -from .const import DOMAIN, OAUTH_SCOPES, PLATFORMS +from .const import OAUTH_SCOPES, PLATFORMS from .coordinator import TwitchConfigEntry, TwitchCoordinator async def async_setup_entry(hass: HomeAssistant, entry: TwitchConfigEntry) -> bool: """Set up Twitch from a config entry.""" - try: - implementation = cast( - LocalOAuth2Implementation, - await async_get_config_entry_implementation(hass, entry), - ) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = cast( + LocalOAuth2Implementation, + await async_get_config_entry_implementation(hass, entry), + ) session = OAuth2Session(hass, entry, implementation) try: await session.async_ensure_token_valid() diff --git a/homeassistant/components/twitch/strings.json b/homeassistant/components/twitch/strings.json index 92c239d4606c..93372966b89c 100644 --- a/homeassistant/components/twitch/strings.json +++ b/homeassistant/components/twitch/strings.json @@ -57,10 +57,5 @@ } } } - }, - "exceptions": { - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - } } } diff --git a/homeassistant/components/vicare/__init__.py b/homeassistant/components/vicare/__init__.py index 931040dda190..9753687ecb3c 100644 --- a/homeassistant/components/vicare/__init__.py +++ b/homeassistant/components/vicare/__init__.py @@ -130,21 +130,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ViCareConfigEntry) -> bo """Set up from config entry.""" _LOGGER.debug("Setting up ViCare component") - try: - implementation = ( - await config_entry_oauth2_flow.async_get_config_entry_implementation( - hass, entry - ) + implementation = ( + await config_entry_oauth2_flow.async_get_config_entry_implementation( + hass, entry ) - except ( - config_entry_oauth2_flow.ImplementationUnavailableError, - ValueError, - ) as err: - # Application Credentials missing or removed — user must re-authenticate - _LOGGER.debug("OAuth2 implementation unavailable: %s", err) - raise ConfigEntryAuthFailed( - "OAuth2 implementation unavailable, please re-authenticate" - ) from err + ) oauth_session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation) try: diff --git a/homeassistant/components/volvo/__init__.py b/homeassistant/components/volvo/__init__.py index 00bb342c9dd8..5808641ab767 100644 --- a/homeassistant/components/volvo/__init__.py +++ b/homeassistant/components/volvo/__init__.py @@ -15,7 +15,6 @@ from homeassistant.exceptions import ( from homeassistant.helpers import config_validation as cv from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -89,13 +88,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: VolvoConfigEntry) -> bo async def _async_auth_and_create_api( hass: HomeAssistant, entry: VolvoConfigEntry ) -> VolvoCarsApi: - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) oauth_session = OAuth2Session(hass, entry, implementation) web_session = async_get_clientsession(hass) auth = VolvoAuth(web_session, oauth_session) diff --git a/homeassistant/components/volvo/strings.json b/homeassistant/components/volvo/strings.json index 5f5204d3cc42..f9280c242a83 100644 --- a/homeassistant/components/volvo/strings.json +++ b/homeassistant/components/volvo/strings.json @@ -365,9 +365,6 @@ "no_vehicle": { "message": "Unable to retrieve vehicle details." }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - }, "unauthorized": { "message": "Authentication failed. {message}" }, diff --git a/homeassistant/components/watts/__init__.py b/homeassistant/components/watts/__init__.py index 3dbb42371de5..6ab432ec5a22 100644 --- a/homeassistant/components/watts/__init__.py +++ b/homeassistant/components/watts/__init__.py @@ -99,17 +99,11 @@ def _handle_new_devices( async def async_setup_entry(hass: HomeAssistant, entry: WattsVisionConfigEntry) -> bool: """Set up Watts Vision from a config entry.""" - try: - implementation = ( - await config_entry_oauth2_flow.async_get_config_entry_implementation( - hass, entry - ) + implementation = ( + await config_entry_oauth2_flow.async_get_config_entry_implementation( + hass, entry ) - except config_entry_oauth2_flow.ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth_implementation_unavailable", - ) from err + ) oauth_session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation) diff --git a/homeassistant/components/watts/strings.json b/homeassistant/components/watts/strings.json index e35e258bde0d..1ecac929bc7b 100644 --- a/homeassistant/components/watts/strings.json +++ b/homeassistant/components/watts/strings.json @@ -58,9 +58,6 @@ "network_issue": { "message": "Network issue during OAuth setup" }, - "oauth_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - }, "oauth_session_not_valid": { "message": "OAuth session not valid" }, diff --git a/homeassistant/components/weheat/__init__.py b/homeassistant/components/weheat/__init__.py index f7d5ffafdb81..254d4d17ed13 100644 --- a/homeassistant/components/weheat/__init__.py +++ b/homeassistant/components/weheat/__init__.py @@ -12,12 +12,11 @@ from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) -from .const import API_URL, DOMAIN, LOGGER +from .const import API_URL, LOGGER from .coordinator import ( HeatPumpInfo, WeheatConfigEntry, @@ -31,13 +30,7 @@ PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.SENSOR] async def async_setup_entry(hass: HomeAssistant, entry: WeheatConfigEntry) -> bool: """Set up Weheat from a config entry.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) diff --git a/homeassistant/components/weheat/strings.json b/homeassistant/components/weheat/strings.json index 4a51c8eadc03..b2a50174e147 100644 --- a/homeassistant/components/weheat/strings.json +++ b/homeassistant/components/weheat/strings.json @@ -144,10 +144,5 @@ "name": "Water outlet temperature" } } - }, - "exceptions": { - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - } } } diff --git a/homeassistant/components/withings/__init__.py b/homeassistant/components/withings/__init__.py index c17025159e40..f4be335a45f7 100644 --- a/homeassistant/components/withings/__init__.py +++ b/homeassistant/components/withings/__init__.py @@ -41,11 +41,9 @@ from homeassistant.const import ( Platform, ) from homeassistant.core import CALLBACK_TYPE, HomeAssistant -from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import device_registry as dr from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -113,13 +111,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: WithingsConfigEntry) -> ) session = async_get_clientsession(hass) client = WithingsClient(session=session) - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) oauth_session = OAuth2Session(hass, entry, implementation) refresh_lock = asyncio.Lock() diff --git a/homeassistant/components/withings/strings.json b/homeassistant/components/withings/strings.json index 2fa3734f2fc6..71d9bb272f87 100644 --- a/homeassistant/components/withings/strings.json +++ b/homeassistant/components/withings/strings.json @@ -328,10 +328,5 @@ } } } - }, - "exceptions": { - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - } } } diff --git a/homeassistant/components/xbox/__init__.py b/homeassistant/components/xbox/__init__.py index 277471c9c8b4..b6d6bcc8c092 100644 --- a/homeassistant/components/xbox/__init__.py +++ b/homeassistant/components/xbox/__init__.py @@ -12,7 +12,6 @@ from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import config_validation as cv, device_registry as dr from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -45,13 +44,7 @@ PLATFORMS = [ async def async_setup_entry(hass: HomeAssistant, entry: XboxConfigEntry) -> bool: """Set up xbox from a config entry.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as e: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from e + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) async_session = get_async_client(hass) @@ -113,13 +106,7 @@ async def async_migrate_entry(hass: HomeAssistant, entry: XboxConfigEntry) -> bo """Migrate config entry.""" if entry.version == 1 and entry.minor_version < 3: - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as e: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from e + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) async_session = get_async_client(hass) auth = AsyncConfigEntryAuth(async_session, session) diff --git a/homeassistant/components/xbox/strings.json b/homeassistant/components/xbox/strings.json index 9d7aa6bf8250..384972aa7bec 100644 --- a/homeassistant/components/xbox/strings.json +++ b/homeassistant/components/xbox/strings.json @@ -160,9 +160,6 @@ "media_not_found": { "message": "The requested media could not be found." }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - }, "request_exception": { "message": "Failed to connect to Xbox Network" }, diff --git a/homeassistant/components/yale/__init__.py b/homeassistant/components/yale/__init__.py index 49bc3850c24c..e1a7bda85c4c 100644 --- a/homeassistant/components/yale/__init__.py +++ b/homeassistant/components/yale/__init__.py @@ -21,7 +21,6 @@ from homeassistant.exceptions import ( ) from homeassistant.helpers import device_registry as dr from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -37,10 +36,7 @@ type YaleConfigEntry = ConfigEntry[YaleData] async def async_setup_entry(hass: HomeAssistant, entry: YaleConfigEntry) -> bool: """Set up Yale from a config entry.""" session = async_create_yale_clientsession(hass) - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady("OAuth implementation not available") from err + implementation = await async_get_config_entry_implementation(hass, entry) oauth_session = OAuth2Session(hass, entry, implementation) yale_gateway = YaleGateway(Path(hass.config.config_dir), session, oauth_session) try: diff --git a/homeassistant/components/yolink/__init__.py b/homeassistant/components/yolink/__init__.py index d491799b3561..595286d2207e 100644 --- a/homeassistant/components/yolink/__init__.py +++ b/homeassistant/components/yolink/__init__.py @@ -20,7 +20,6 @@ from homeassistant.helpers import ( device_registry as dr, ) from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -108,13 +107,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: YoLinkConfigEntry) -> bool: """Set up yolink from a config entry.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) diff --git a/homeassistant/components/yolink/strings.json b/homeassistant/components/yolink/strings.json index 840733240e41..479908c15e0e 100644 --- a/homeassistant/components/yolink/strings.json +++ b/homeassistant/components/yolink/strings.json @@ -129,9 +129,6 @@ "invalid_config_entry": { "message": "Config entry not found or not loaded!" }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - }, "valve_inoperable_currently": { "message": "The Valve cannot be operated currently." } diff --git a/homeassistant/components/yoto/__init__.py b/homeassistant/components/yoto/__init__.py index 1f068d64cc82..e20d0cbad886 100644 --- a/homeassistant/components/yoto/__init__.py +++ b/homeassistant/components/yoto/__init__.py @@ -11,7 +11,6 @@ from homeassistant.exceptions import ( OAuth2TokenRequestReauthError, ) from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -32,13 +31,7 @@ PLATFORMS: list[Platform] = [ async def async_setup_entry(hass: HomeAssistant, entry: YotoConfigEntry) -> bool: """Set up Yoto from a config entry.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) try: diff --git a/homeassistant/components/yoto/strings.json b/homeassistant/components/yoto/strings.json index cb832fd390fd..154704c916c5 100644 --- a/homeassistant/components/yoto/strings.json +++ b/homeassistant/components/yoto/strings.json @@ -136,9 +136,6 @@ "invalid_media_id": { "message": "Not a Yoto media identifier: {media_id}" }, - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - }, "play_failed": { "message": "Failed to play Yoto media: {error}" }, diff --git a/homeassistant/components/youtube/__init__.py b/homeassistant/components/youtube/__init__.py index b6f12c7efc9c..a4a494442a55 100644 --- a/homeassistant/components/youtube/__init__.py +++ b/homeassistant/components/youtube/__init__.py @@ -12,13 +12,11 @@ from homeassistant.exceptions import ( ) from homeassistant.helpers import device_registry as dr from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) from .api import AsyncConfigEntryAuth -from .const import DOMAIN from .coordinator import YouTubeConfigEntry, YouTubeDataUpdateCoordinator PLATFORMS = [Platform.SENSOR] @@ -26,13 +24,7 @@ PLATFORMS = [Platform.SENSOR] async def async_setup_entry(hass: HomeAssistant, entry: YouTubeConfigEntry) -> bool: """Set up YouTube from a config entry.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - translation_domain=DOMAIN, - translation_key="oauth2_implementation_unavailable", - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) auth = AsyncConfigEntryAuth(hass, session) try: diff --git a/homeassistant/components/youtube/strings.json b/homeassistant/components/youtube/strings.json index eb8fb14c4458..a4cdc32a4950 100644 --- a/homeassistant/components/youtube/strings.json +++ b/homeassistant/components/youtube/strings.json @@ -55,11 +55,6 @@ "views": { "name": "Views" } } }, - "exceptions": { - "oauth2_implementation_unavailable": { - "message": "[%key:common::exceptions::oauth2_implementation_unavailable::message%]" - } - }, "options": { "step": { "init": { diff --git a/script/scaffold/templates/config_flow_oauth2/integration/__init__.py b/script/scaffold/templates/config_flow_oauth2/integration/__init__.py index 4b3837034401..77950552d6e2 100644 --- a/script/scaffold/templates/config_flow_oauth2/integration/__init__.py +++ b/script/scaffold/templates/config_flow_oauth2/integration/__init__.py @@ -3,10 +3,8 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import Platform from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import aiohttp_client from homeassistant.helpers.config_entry_oauth2_flow import ( - ImplementationUnavailableError, OAuth2Session, async_get_config_entry_implementation, ) @@ -25,12 +23,7 @@ type New_NameConfigEntry = ConfigEntry[api.AsyncConfigEntryAuth] # # TODO Update entry annotation async def async_setup_entry(hass: HomeAssistant, entry: New_NameConfigEntry) -> bool: """Set up NEW_NAME from a config entry.""" - try: - implementation = await async_get_config_entry_implementation(hass, entry) - except ImplementationUnavailableError as err: - raise ConfigEntryNotReady( - "OAuth2 implementation temporarily unavailable, will retry" - ) from err + implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) diff --git a/tests/components/youtube/__init__.py b/tests/components/youtube/__init__.py index 56c5dcd7226b..65e03b44f030 100644 --- a/tests/components/youtube/__init__.py +++ b/tests/components/youtube/__init__.py @@ -5,7 +5,7 @@ from collections.abc import AsyncGenerator from youtubeaio.models import YouTubeChannel, YouTubePlaylistItem, YouTubeSubscription from youtubeaio.types import AuthScope -from homeassistant.components.youtube import DOMAIN +from homeassistant.components.youtube.const import DOMAIN from homeassistant.core import HomeAssistant from tests.common import async_load_json_object_fixture diff --git a/tests/components/youtube/test_init.py b/tests/components/youtube/test_init.py index bbcb86fc424e..58c13b634d3e 100644 --- a/tests/components/youtube/test_init.py +++ b/tests/components/youtube/test_init.py @@ -7,8 +7,7 @@ from unittest.mock import patch from aiohttp.client_exceptions import ClientError import pytest -from homeassistant.components.youtube import DOMAIN -from homeassistant.components.youtube.const import CONF_CHANNELS +from homeassistant.components.youtube.const import CONF_CHANNELS, DOMAIN from homeassistant.config_entries import ConfigEntryState from homeassistant.core import HomeAssistant from homeassistant.helpers import device_registry as dr