From 336ba62eaad25bda3a94426bd21d0de8b3ed0a29 Mon Sep 17 00:00:00 2001 From: "Ian C." <108159253+ic-dev21@users.noreply.github.com> Date: Tue, 17 Jun 2025 21:11:30 -0400 Subject: [PATCH] Revert "Disable session cookie quoting to work with aiohttp v3.12.12" --- custom_components/hilo/__init__.py | 7 ++----- custom_components/hilo/oauth2.py | 16 ---------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/custom_components/hilo/__init__.py b/custom_components/hilo/__init__.py index 554648a4..29afca62 100644 --- a/custom_components/hilo/__init__.py +++ b/custom_components/hilo/__init__.py @@ -8,7 +8,6 @@ import traceback from typing import TYPE_CHECKING, List, Optional -from aiohttp import CookieJar from homeassistant.components.select import ( ATTR_OPTION, DOMAIN as SELECT_DOMAIN, @@ -27,11 +26,11 @@ from homeassistant.core import Context, Event, HomeAssistant, callback from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.helpers import ( + aiohttp_client, config_entry_oauth2_flow, device_registry as dr, entity_registry as er, ) -from homeassistant.helpers.aiohttp_client import async_create_clientsession from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.event import async_call_later from homeassistant.helpers.update_coordinator import DataUpdateCoordinator @@ -141,9 +140,7 @@ async def async_setup_entry( # noqa: C901 try: api = await API.async_create( - session=async_create_clientsession( - hass, cookie_jar=CookieJar(quote_cookie=False) - ), + session=aiohttp_client.async_get_clientsession(hass), oauth_session=config_entry_oauth2_flow.OAuth2Session( hass, entry, implementation ), diff --git a/custom_components/hilo/oauth2.py b/custom_components/hilo/oauth2.py index 78527185..d827a3dd 100644 --- a/custom_components/hilo/oauth2.py +++ b/custom_components/hilo/oauth2.py @@ -2,9 +2,7 @@ from typing import Any, cast -from aiohttp import CookieJar from homeassistant.core import HomeAssistant -from homeassistant.helpers.aiohttp_client import async_create_clientsession from homeassistant.helpers.config_entry_oauth2_flow import LocalOAuth2Implementation from pyhilo.const import AUTH_AUTHORIZE, AUTH_CLIENT_ID, AUTH_TOKEN, DOMAIN from pyhilo.oauth2helper import OAuth2Helper @@ -27,9 +25,6 @@ def __init__( AUTH_TOKEN, ) - self.session = async_create_clientsession( - self.hass, cookie_jar=CookieJar(quote_cookie=False) - ) self.oauth_helper = OAuth2Helper() # ... Override AbstractOAuth2Implementation details @@ -53,14 +48,3 @@ async def async_resolve_external_data(self, external_data: Any) -> dict: ) ), ) - - async def _token_request(self, data: dict) -> dict: - """Make a token request.""" - data["client_id"] = self.client_id - - if self.client_secret: - data["client_secret"] = self.client_secret - - resp = await self.session.post(self.token_url, data=data) - resp.raise_for_status() - return cast(dict, await resp.json())