Home Assistant Unofficial Reference
2024.12.1
api.py
Go to the documentation of this file.
1
"""API for nVent RAYCHEM SENZ bound to Home Assistant OAuth."""
2
3
from
typing
import
cast
4
5
from
aiosenz
import
AbstractSENZAuth
6
from
httpx
import
AsyncClient
7
8
from
homeassistant.helpers
import
config_entry_oauth2_flow
9
10
11
class
SENZConfigEntryAuth
(AbstractSENZAuth):
12
"""Provide nVent RAYCHEM SENZ authentication tied to an OAuth2 based config entry."""
13
14
def
__init__
(
15
self,
16
httpx_async_client: AsyncClient,
17
oauth_session: config_entry_oauth2_flow.OAuth2Session,
18
) ->
None
:
19
"""Initialize SENZ auth."""
20
super().
__init__
(httpx_async_client)
21
self.
_oauth_session
_oauth_session = oauth_session
22
23
async
def
get_access_token
(self) -> str:
24
"""Return a valid access token."""
25
await self.
_oauth_session
_oauth_session.async_ensure_token_valid()
26
return
cast(str, self.
_oauth_session
_oauth_session.token[
"access_token"
])
homeassistant.components.senz.api.SENZConfigEntryAuth
Definition:
api.py:11
homeassistant.components.senz.api.SENZConfigEntryAuth.__init__
None __init__(self, AsyncClient httpx_async_client, config_entry_oauth2_flow.OAuth2Session oauth_session)
Definition:
api.py:18
homeassistant.components.senz.api.SENZConfigEntryAuth._oauth_session
_oauth_session
Definition:
api.py:21
homeassistant.components.senz.api.SENZConfigEntryAuth.get_access_token
str get_access_token(self)
Definition:
api.py:23
homeassistant.helpers
Definition:
__init__.py:1
core
homeassistant
components
senz
api.py
Generated by
1.9.1