diff --git a/homeassistant/components/google_mail/__init__.py b/homeassistant/components/google_mail/__init__.py index 7e5281630bc..15c4192ccf5 100644 --- a/homeassistant/components/google_mail/__init__.py +++ b/homeassistant/components/google_mail/__init__.py @@ -8,7 +8,6 @@ from homeassistant.const import CONF_NAME, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.helpers import config_validation as cv, discovery -from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.config_entry_oauth2_flow import ( OAuth2Session, async_get_config_entry_implementation, @@ -35,7 +34,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Google Mail from a config entry.""" implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) - auth = AsyncConfigEntryAuth(async_get_clientsession(hass), session) + auth = AsyncConfigEntryAuth(session) try: await auth.check_and_refresh_token() except ClientResponseError as err: diff --git a/homeassistant/components/google_mail/api.py b/homeassistant/components/google_mail/api.py index 202fa5b56b6..ffa33deae14 100644 --- a/homeassistant/components/google_mail/api.py +++ b/homeassistant/components/google_mail/api.py @@ -1,25 +1,21 @@ """API for Google Mail bound to Home Assistant OAuth.""" -from aiohttp import ClientSession from google.auth.exceptions import RefreshError from google.oauth2.credentials import Credentials -from google.oauth2.utils import OAuthClientAuthHandler from googleapiclient.discovery import Resource, build from homeassistant.const import CONF_ACCESS_TOKEN from homeassistant.helpers import config_entry_oauth2_flow -class AsyncConfigEntryAuth(OAuthClientAuthHandler): +class AsyncConfigEntryAuth: """Provide Google Mail authentication tied to an OAuth2 based config entry.""" def __init__( self, - websession: ClientSession, - oauth2Session: config_entry_oauth2_flow.OAuth2Session, + oauth2_session: config_entry_oauth2_flow.OAuth2Session, ) -> None: """Initialize Google Mail Auth.""" - self.oauth_session = oauth2Session - super().__init__(websession) + self.oauth_session = oauth2_session @property def access_token(self) -> str: