1 """The Google Tasks integration."""
3 from __future__
import annotations
5 from aiohttp
import ClientError, ClientResponseError
14 from .const
import DOMAIN
16 PLATFORMS: list[Platform] = [Platform.TODO]
20 """Set up Google Tasks from a config entry."""
22 await config_entry_oauth2_flow.async_get_config_entry_implementation(
26 session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation)
29 await auth.async_get_access_token()
30 except ClientResponseError
as err:
31 if 400 <= err.status < 500:
33 "OAuth session is not valid, reauth required"
35 raise ConfigEntryNotReady
from err
36 except ClientError
as err:
37 raise ConfigEntryNotReady
from err
39 hass.data.setdefault(DOMAIN, {})[entry.entry_id] = auth
41 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
47 """Unload a config entry."""
48 if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
49 hass.data[DOMAIN].pop(entry.entry_id)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)