|
6 | 6 | import uuid
|
7 | 7 | import base64
|
8 | 8 | import hashlib
|
| 9 | +import json |
9 | 10 | import asyncio
|
10 | 11 | import httpx
|
11 | 12 | from urllib import parse
|
12 |
| -from typing import Optional |
| 13 | +from typing import Optional, Tuple |
13 | 14 |
|
14 | 15 | import ms_cv
|
15 | 16 | from auth.signed_session import SignedSession
|
@@ -121,6 +122,58 @@ async def _get_device_token(self) -> httpx.Response:
|
121 | 122 | request = self.session.build_request('POST', url, headers=headers, json=post_body)
|
122 | 123 | return await self.session.send_signed(request)
|
123 | 124 |
|
| 125 | + async def _get_title_token( |
| 126 | + self, device_token: str, access_token: str |
| 127 | + ) -> httpx.Response: |
| 128 | + url = "https://title.auth.xboxlive.com/title/authenticate" |
| 129 | + headers = {"x-xbl-contract-version": "1", "MS-CV": self.cv.increment()} |
| 130 | + post_body = { |
| 131 | + "RelyingParty": "http://auth.xboxlive.com", |
| 132 | + "TokenType": "JWT", |
| 133 | + "Properties": { |
| 134 | + "AuthMethod": "RPS", |
| 135 | + "DeviceToken": device_token, |
| 136 | + "RpsTicket": f"t={access_token}", |
| 137 | + "SiteName": "user.auth.xboxlive.com", |
| 138 | + }, |
| 139 | + } |
| 140 | + |
| 141 | + request = self.session.build_request( |
| 142 | + "POST", url, headers=headers, json=post_body |
| 143 | + ) |
| 144 | + return await self.session.send_signed(request) |
| 145 | + |
| 146 | + async def get_title_token2( |
| 147 | + self, |
| 148 | + device_token: str, |
| 149 | + title_id: str = "49312658", |
| 150 | + title_version: str = "10.0.10011.16384", |
| 151 | + title_build: str = "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF", |
| 152 | + title_content_id: str = "73DE1908-F71B-4C5C-821E-ED00A426E221", |
| 153 | + ) -> httpx.Response: |
| 154 | + url = "https://title.auth.xboxlive.com/title/authenticate" |
| 155 | + headers = {"x-xbl-contract-version": "1", "MS-CV": self.cv.increment()} |
| 156 | + post_body = { |
| 157 | + "RelyingParty": "http://auth.xboxlive.com", |
| 158 | + "TokenType": "JWT", |
| 159 | + "Properties": { |
| 160 | + "DeviceToken": device_token, |
| 161 | + "TitleAttestation": json.dumps( |
| 162 | + { |
| 163 | + "Id": title_id, |
| 164 | + "Version": title_version, |
| 165 | + "Build": title_build, |
| 166 | + "ContentId": title_content_id, |
| 167 | + } |
| 168 | + ), |
| 169 | + }, |
| 170 | + } |
| 171 | + |
| 172 | + request = self.session.build_request( |
| 173 | + "POST", url, headers=headers, json=post_body |
| 174 | + ) |
| 175 | + return await self.session.send_signed(request) |
| 176 | + |
124 | 177 | async def _do_sisu_authentication(
|
125 | 178 | self,
|
126 | 179 | device_token_jwt: str,
|
@@ -277,7 +330,7 @@ async def sisu_authentication(
|
277 | 330 | device_token: str,
|
278 | 331 | code_challenge: str,
|
279 | 332 | state: str
|
280 |
| - ) -> (SisuAuthenticationResponse, str): |
| 333 | + ) -> Tuple[SisuAuthenticationResponse, str]: |
281 | 334 | print('::: SISU AUTHENTICATION :::')
|
282 | 335 | resp = await self._do_sisu_authentication(device_token, code_challenge, state)
|
283 | 336 | assert resp.status_code == 200,\
|
|
0 commit comments