1
0
mirror of https://github.com/home-assistant/core.git synced 2026-08-06 05:14:06 +01:00
Files
2026-06-22 20:52:27 +02:00

28 lines
866 B
Python

"""API for nVent RAYCHEM SENZ bound to Home Assistant OAuth."""
from typing import cast, override
from httpx import AsyncClient
from pysenz import AbstractSENZAuth
from homeassistant.helpers import config_entry_oauth2_flow
class SENZConfigEntryAuth(AbstractSENZAuth):
"""Provide nVent RAYCHEM SENZ authentication tied to an OAuth2 config entry."""
def __init__(
self,
httpx_async_client: AsyncClient,
oauth_session: config_entry_oauth2_flow.OAuth2Session,
) -> None:
"""Initialize SENZ auth."""
super().__init__(httpx_async_client)
self._oauth_session = oauth_session
@override
async def get_access_token(self) -> str:
"""Return a valid access token."""
await self._oauth_session.async_ensure_token_valid()
return cast(str, self._oauth_session.token["access_token"])