mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +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.provider.smartglass.models import SmartglassConsoleList
|
||||
from xbox.webapi.common.signed_session import SignedSession
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
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)
|
||||
auth = api.AsyncConfigEntryAuth(session)
|
||||
signed_session = await hass.async_add_executor_job(SignedSession)
|
||||
auth = api.AsyncConfigEntryAuth(signed_session, session)
|
||||
|
||||
client = XboxLiveClient(auth)
|
||||
consoles: SmartglassConsoleList = await client.smartglass.get_console_list()
|
||||
|
@ -11,10 +11,12 @@ from homeassistant.util.dt import utc_from_timestamp
|
||||
class AsyncConfigEntryAuth(AuthenticationManager):
|
||||
"""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."""
|
||||
# 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 = self._get_oauth_token()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user