mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 14:57:09 +00:00
Create Xbox signed session in executor (#136927)
This commit is contained in:
parent
bab616fa61
commit
232e99b62e
@ -6,6 +6,7 @@ import logging
|
|||||||
|
|
||||||
from xbox.webapi.api.client import XboxLiveClient
|
from xbox.webapi.api.client import XboxLiveClient
|
||||||
from xbox.webapi.api.provider.smartglass.models import SmartglassConsoleList
|
from xbox.webapi.api.provider.smartglass.models import SmartglassConsoleList
|
||||||
|
from xbox.webapi.common.signed_session import SignedSession
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
@ -36,7 +37,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation)
|
session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation)
|
||||||
auth = api.AsyncConfigEntryAuth(session)
|
signed_session = await hass.async_add_executor_job(SignedSession)
|
||||||
|
auth = api.AsyncConfigEntryAuth(signed_session, session)
|
||||||
|
|
||||||
client = XboxLiveClient(auth)
|
client = XboxLiveClient(auth)
|
||||||
consoles: SmartglassConsoleList = await client.smartglass.get_console_list()
|
consoles: SmartglassConsoleList = await client.smartglass.get_console_list()
|
||||||
|
@ -11,10 +11,12 @@ from homeassistant.util.dt import utc_from_timestamp
|
|||||||
class AsyncConfigEntryAuth(AuthenticationManager):
|
class AsyncConfigEntryAuth(AuthenticationManager):
|
||||||
"""Provide xbox authentication tied to an OAuth2 based config entry."""
|
"""Provide xbox authentication tied to an OAuth2 based config entry."""
|
||||||
|
|
||||||
def __init__(self, oauth_session: OAuth2Session) -> None:
|
def __init__(
|
||||||
|
self, signed_session: SignedSession, oauth_session: OAuth2Session
|
||||||
|
) -> None:
|
||||||
"""Initialize xbox auth."""
|
"""Initialize xbox auth."""
|
||||||
# Leaving out client credentials as they are handled by Home Assistant
|
# Leaving out client credentials as they are handled by Home Assistant
|
||||||
super().__init__(SignedSession(), "", "", "")
|
super().__init__(signed_session, "", "", "")
|
||||||
self._oauth_session = oauth_session
|
self._oauth_session = oauth_session
|
||||||
self.oauth = self._get_oauth_token()
|
self.oauth = self._get_oauth_token()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user