Skip to content

Create Xbox signed session in executor #136927

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion homeassistant/components/xbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

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
Expand Down Expand Up @@ -36,7 +37,8 @@
)
)
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)

Check warning on line 41 in homeassistant/components/xbox/__init__.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/xbox/__init__.py#L40-L41

Added lines #L40 - L41 were not covered by tests

client = XboxLiveClient(auth)
consoles: SmartglassConsoleList = await client.smartglass.get_console_list()
Expand Down
6 changes: 4 additions & 2 deletions homeassistant/components/xbox/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
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, "", "", "")

Check warning on line 19 in homeassistant/components/xbox/api.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/xbox/api.py#L19

Added line #L19 was not covered by tests
self._oauth_session = oauth_session
self.oauth = self._get_oauth_token()

Expand Down