mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Remove superclass from YouTube (#95002)
This commit is contained in:
parent
6230a51695
commit
492ed1b544
@ -7,7 +7,6 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
|
||||||
from homeassistant.helpers.config_entry_oauth2_flow import (
|
from homeassistant.helpers.config_entry_oauth2_flow import (
|
||||||
OAuth2Session,
|
OAuth2Session,
|
||||||
async_get_config_entry_implementation,
|
async_get_config_entry_implementation,
|
||||||
@ -24,7 +23,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
"""Set up YouTube from a config entry."""
|
"""Set up YouTube from a config entry."""
|
||||||
implementation = await async_get_config_entry_implementation(hass, entry)
|
implementation = await async_get_config_entry_implementation(hass, entry)
|
||||||
session = OAuth2Session(hass, entry, implementation)
|
session = OAuth2Session(hass, entry, implementation)
|
||||||
auth = AsyncConfigEntryAuth(hass, async_get_clientsession(hass), session)
|
auth = AsyncConfigEntryAuth(hass, session)
|
||||||
try:
|
try:
|
||||||
await auth.check_and_refresh_token()
|
await auth.check_and_refresh_token()
|
||||||
except ClientResponseError as err:
|
except ClientResponseError as err:
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
"""API for YouTube bound to Home Assistant OAuth."""
|
"""API for YouTube bound to Home Assistant OAuth."""
|
||||||
from aiohttp import ClientSession
|
|
||||||
from google.auth.exceptions import RefreshError
|
from google.auth.exceptions import RefreshError
|
||||||
from google.oauth2.credentials import Credentials
|
from google.oauth2.credentials import Credentials
|
||||||
from google.oauth2.utils import OAuthClientAuthHandler
|
|
||||||
from googleapiclient.discovery import Resource, build
|
from googleapiclient.discovery import Resource, build
|
||||||
|
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||||
@ -10,19 +8,17 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers import config_entry_oauth2_flow
|
from homeassistant.helpers import config_entry_oauth2_flow
|
||||||
|
|
||||||
|
|
||||||
class AsyncConfigEntryAuth(OAuthClientAuthHandler):
|
class AsyncConfigEntryAuth:
|
||||||
"""Provide Google authentication tied to an OAuth2 based config entry."""
|
"""Provide Google authentication tied to an OAuth2 based config entry."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
websession: ClientSession,
|
|
||||||
oauth2_session: config_entry_oauth2_flow.OAuth2Session,
|
oauth2_session: config_entry_oauth2_flow.OAuth2Session,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize YouTube Auth."""
|
"""Initialize YouTube Auth."""
|
||||||
self.oauth_session = oauth2_session
|
self.oauth_session = oauth2_session
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
super().__init__(websession)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def access_token(self) -> str:
|
def access_token(self) -> str:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user