1 """API for Honeywell Lyric bound to Home Assistant OAuth."""
3 from typing
import cast
5 from aiohttp
import BasicAuth, ClientSession
6 from aiolyric.client
import LyricClient
14 """OAuth2Session for Lyric."""
17 """Force a token refresh."""
18 new_token = await self.implementation.async_refresh_token(self.token)
20 self.hass.config_entries.async_update_entry(
21 self.config_entry, data={**self.config_entry.data,
"token": new_token}
26 """Provide Honeywell Lyric authentication tied to an OAuth2 based config entry."""
30 websession: ClientSession,
31 oauth_session: config_entry_oauth2_flow.OAuth2Session,
33 """Initialize Honeywell Lyric auth."""
38 """Return a valid access token."""
47 """Lyric Local OAuth2 implementation."""
50 """Make a token request."""
53 data[
"client_id"] = self.client_id
55 if self.client_secret
is not None:
56 data[
"client_secret"] = self.client_secret
59 "Authorization": BasicAuth(self.client_id, self.client_secret).encode(),
60 "Content-Type":
"application/x-www-form-urlencoded",
63 resp = await session.post(self.token_url, headers=headers, data=data)
64 resp.raise_for_status()
65 return cast(dict, await resp.json())
def async_get_access_token(self)
None __init__(self, ClientSession websession, config_entry_oauth2_flow.OAuth2Session oauth_session)
dict _token_request(self, dict data)
None force_refresh_token(self)
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)