Skip to content

Commit e4c2cc1

Browse files
committed
Fixes to XCloud, call as default - make sure to delete appconfig.json for new Xal params to propagate!
1 parent c7cfec6 commit e4c2cc1

File tree

3 files changed

+46
-20
lines changed

3 files changed

+46
-20
lines changed

auth/xal_auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ async def _exchange_code_for_token(
183183

184184
return await self.__oauth20_token_endpoint(post_body)
185185

186-
async def _exchange_refresh_token_for_xcloud_transfer_token(
186+
async def exchange_refresh_token_for_xcloud_transfer_token(
187187
self,
188188
refresh_token_jwt: str
189189
) -> XCloudTokenResponse:

main.py

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55

66
from common import AppConfiguration
77

8-
from auth.constants import IOS_XBOXBETA_APP_PARAMS
8+
from auth.constants import IOS_XBOXBETA_APP_PARAMS, ANDROID_GAMEPASS_BETA_PARAMS
99
from auth.models import XalClientParameters, XSTSResponse
1010
from auth.xal_auth import XalAuthenticator
1111
from auth.request_signer import RequestSigner
1212

1313
from smartglass_api import SmartglassApi
14+
from xcloud_api import XCloudApi
1415
from xhomestreaming_api import XHomeStreamingApi
1516

1617
APP_CONFIG_FILE = "appconfig.json"
@@ -66,6 +67,33 @@ async def test_xhome_streaming(
6667
await xhome_api.session.aclose()
6768

6869

70+
async def test_xcloud_streaming(
71+
config: AppConfiguration
72+
):
73+
xal = XalAuthenticator(
74+
config.ClientUUID,
75+
config.XalParameters,
76+
RequestSigner.from_pem(config.SigningKey)
77+
)
78+
79+
print(':: Requesting XSTS Token (RelyingParty: http://gssv.xboxlive.com)')
80+
gssv_token = await xal.xsts_authorization(
81+
config.Authorization.DeviceToken,
82+
config.Authorization.TitleToken.Token,
83+
config.Authorization.UserToken.Token,
84+
relying_party='http://gssv.xboxlive.com/'
85+
)
86+
print(':: Exchanging refresh token for xcloud transfer token')
87+
xcloud_token = await xal.exchange_refresh_token_for_xcloud_transfer_token(
88+
config.WindowsLiveTokens.refresh_token
89+
)
90+
await xal.session.aclose()
91+
92+
xhome_api = XCloudApi(gssv_token, xcloud_token)
93+
await xhome_api.start_streaming()
94+
await xhome_api.session.aclose()
95+
96+
6997
async def main():
7098
"""
7199
Prepare needed values
@@ -80,7 +108,7 @@ async def main():
80108
ClientUUID=uuid.uuid4(),
81109
SigningKey=RequestSigner().export_signing_key(),
82110
XalParameters=XalClientParameters.parse_obj(
83-
IOS_XBOXBETA_APP_PARAMS
111+
ANDROID_GAMEPASS_BETA_PARAMS # NOTE: XBOXBETA APP -> XHOME, XBOXGAMEPASS BETA -> XCLOUD!
84112
)
85113
)
86114

@@ -105,6 +133,7 @@ async def main():
105133
with io.open(APP_CONFIG_FILE, 'wt') as f:
106134
f.write(config.json(indent=2))
107135

136+
"""
108137
smartglass = SmartglassApi(
109138
request_signer,
110139
config.Authorization.AuthorizationToken
@@ -116,9 +145,11 @@ async def main():
116145
117146
console = choose_console(console_list)
118147
console_liveid = console.id
148+
"""
119149

120150
# test_smartglass_api(smartglass, console_liveid)
121-
await test_xhome_streaming(config, console_liveid)
151+
await test_xcloud_streaming(config)
152+
# await test_xhome_streaming(config, console_liveid)
122153

123154

124155
if __name__ == '__main__':

xcloud_api.py

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -181,27 +181,22 @@ async def start_streaming(self):
181181
stream_session = await self._request_stream(base_url, gametitle.titleId)
182182
print(f':: Stream session {stream_session}')
183183

184-
print(':: Waiting for stream ReadyToConnect...')
184+
print(':: Waiting for stream')
185185
while True:
186186
state = await self._get_session_state(base_url, stream_session.sessionPath)
187+
print(state.state)
187188
if state.state == StreamSetupState.ReadyToConnect:
189+
print(':: Connecting to stream')
190+
success = await self._connect_to_session(
191+
base_url, stream_session.sessionPath, self.xcloud_token.lpt
192+
)
193+
if not success:
194+
print(':: Failed to connect to session')
195+
return
196+
elif state.state == StreamSetupState.Provisioned:
188197
break
189-
await asyncio.sleep(100)
190198

191-
print(':: Connecting to stream')
192-
success = await self._connect_to_session(
193-
base_url, stream_session.sessionPath, self.xcloud_token.lpt
194-
)
195-
if not success:
196-
print(':: Failed to connect to session')
197-
return
198-
199-
print(':: Waiting for provisioning')
200-
while True:
201-
state = await self._get_session_state(base_url, stream_session.sessionPath)
202-
if state.state == StreamSetupState.Provisioned:
203-
break
204-
await asyncio.sleep(100)
199+
await asyncio.sleep(1)
205200

206201
print(':: Requesting config')
207202
config = await self._get_stream_config(base_url, stream_session.sessionPath)

0 commit comments

Comments
 (0)