mirror of
https://github.com/home-assistant/core.git
synced 2026-07-02 04:06:41 +01:00
daffc8c2ce
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: frenck <195327+frenck@users.noreply.github.com>
27 lines
842 B
Python
27 lines
842 B
Python
"""API for nVent RAYCHEM SENZ bound to Home Assistant OAuth."""
|
|
|
|
from typing import cast
|
|
|
|
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
|
|
|
|
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"])
|