55
66from 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
99from auth .models import XalClientParameters , XSTSResponse
1010from auth .xal_auth import XalAuthenticator
1111from auth .request_signer import RequestSigner
1212
1313from smartglass_api import SmartglassApi
14+ from xcloud_api import XCloudApi
1415from xhomestreaming_api import XHomeStreamingApi
1516
1617APP_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+
6997async 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
124155if __name__ == '__main__' :
0 commit comments