Skip to content
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
2 changes: 1 addition & 1 deletion src/pythonxbox/api/provider/presence/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async def get_presence_batch(
url, json=post_data, headers=self.HEADERS_PRESENCE, **kwargs
)
resp.raise_for_status()
parsed = PresenceBatchResponse.model_validate(resp.json())
parsed = PresenceBatchResponse.model_validate_json(resp.text)
return parsed.root

async def get_presence_own(
Expand Down
23 changes: 12 additions & 11 deletions src/pythonxbox/authentication/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@


class AuthenticationManager:
oauth: OAuth2TokenResponse | None = None
user_token: XAUResponse | None = None
xsts_token: XSTSResponse | None = None

def __init__(
self,
client_session: SignedSession | httpx.AsyncClient,
Expand All @@ -32,14 +36,10 @@ def __init__(
scopes: list[str] | None = None,
) -> None:
self.session = client_session
self._client_id: str = client_id
self._client_secret: str = client_secret
self._redirect_uri: str = redirect_uri
self._scopes: list[str] = scopes or DEFAULT_SCOPES

self.oauth: OAuth2TokenResponse = None
self.user_token: XAUResponse = None
self.xsts_token: XSTSResponse = None
self._client_id = client_id
self._client_secret = client_secret
self._redirect_uri = redirect_uri
self._scopes = scopes or DEFAULT_SCOPES

def generate_authorization_url(self, state: str | None = None) -> str:
"""Generate Windows Live Authorization URL."""
Expand Down Expand Up @@ -148,9 +148,10 @@ async def request_xsts_token(

resp = await self.session.post(url, json=data, headers=headers)
if resp.status_code == HTTPStatus.UNAUTHORIZED: # if unauthorized
print(
"Failed to authorize you! Your password or username may be wrong or you are trying to use child account (< 18 years old)"
msg = (
"Failed to authorize you! Your password or username may be wrong or"
" you are trying to use child account (< 18 years old)"
)
raise AuthenticationException()
raise AuthenticationException(msg)
resp.raise_for_status()
return XSTSResponse.model_validate_json(resp.text)
Loading