python-xbox 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- python_xbox-0.1.0.dist-info/METADATA +217 -0
- python_xbox-0.1.0.dist-info/RECORD +64 -0
- python_xbox-0.1.0.dist-info/WHEEL +4 -0
- python_xbox-0.1.0.dist-info/entry_points.txt +6 -0
- python_xbox-0.1.0.dist-info/licenses/LICENSE +20 -0
- pythonxbox/__init__.py +4 -0
- pythonxbox/api/__init__.py +0 -0
- pythonxbox/api/client.py +166 -0
- pythonxbox/api/language.py +76 -0
- pythonxbox/api/provider/__init__.py +0 -0
- pythonxbox/api/provider/account/__init__.py +73 -0
- pythonxbox/api/provider/account/models.py +11 -0
- pythonxbox/api/provider/achievements/__init__.py +164 -0
- pythonxbox/api/provider/achievements/models.py +133 -0
- pythonxbox/api/provider/baseprovider.py +22 -0
- pythonxbox/api/provider/catalog/__init__.py +86 -0
- pythonxbox/api/provider/catalog/const.py +15 -0
- pythonxbox/api/provider/catalog/models.py +428 -0
- pythonxbox/api/provider/cqs/__init__.py +85 -0
- pythonxbox/api/provider/cqs/models.py +59 -0
- pythonxbox/api/provider/gameclips/__init__.py +167 -0
- pythonxbox/api/provider/gameclips/models.py +58 -0
- pythonxbox/api/provider/lists/__init__.py +71 -0
- pythonxbox/api/provider/lists/models.py +33 -0
- pythonxbox/api/provider/mediahub/__init__.py +64 -0
- pythonxbox/api/provider/mediahub/models.py +82 -0
- pythonxbox/api/provider/message/__init__.py +135 -0
- pythonxbox/api/provider/message/models.py +96 -0
- pythonxbox/api/provider/people/__init__.py +193 -0
- pythonxbox/api/provider/people/models.py +252 -0
- pythonxbox/api/provider/presence/__init__.py +110 -0
- pythonxbox/api/provider/presence/models.py +53 -0
- pythonxbox/api/provider/profile/__init__.py +140 -0
- pythonxbox/api/provider/profile/models.py +47 -0
- pythonxbox/api/provider/ratelimitedprovider.py +79 -0
- pythonxbox/api/provider/screenshots/__init__.py +167 -0
- pythonxbox/api/provider/screenshots/models.py +56 -0
- pythonxbox/api/provider/smartglass/__init__.py +402 -0
- pythonxbox/api/provider/smartglass/models.py +186 -0
- pythonxbox/api/provider/titlehub/__init__.py +143 -0
- pythonxbox/api/provider/titlehub/models.py +106 -0
- pythonxbox/api/provider/usersearch/__init__.py +29 -0
- pythonxbox/api/provider/usersearch/models.py +17 -0
- pythonxbox/api/provider/userstats/__init__.py +164 -0
- pythonxbox/api/provider/userstats/models.py +44 -0
- pythonxbox/authentication/__init__.py +0 -0
- pythonxbox/authentication/manager.py +161 -0
- pythonxbox/authentication/models.py +162 -0
- pythonxbox/authentication/xal.py +348 -0
- pythonxbox/common/__init__.py +0 -0
- pythonxbox/common/exceptions.py +59 -0
- pythonxbox/common/filetimes.py +81 -0
- pythonxbox/common/models.py +34 -0
- pythonxbox/common/ratelimits/__init__.py +268 -0
- pythonxbox/common/ratelimits/models.py +23 -0
- pythonxbox/common/request_signer.py +190 -0
- pythonxbox/common/signed_session.py +60 -0
- pythonxbox/py.typed +0 -0
- pythonxbox/scripts/__init__.py +15 -0
- pythonxbox/scripts/authenticate.py +159 -0
- pythonxbox/scripts/change_gamertag.py +111 -0
- pythonxbox/scripts/friends.py +80 -0
- pythonxbox/scripts/search.py +43 -0
- pythonxbox/scripts/xal.py +113 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-xbox
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A library to authenticate with Xbox Network and use their API
|
|
5
|
+
Project-URL: Source, https://github.com/tr4nt0r/python-xbox
|
|
6
|
+
Author: OpenXbox
|
|
7
|
+
Author-email: Manfred Dennerlein Rodelo <manfred@dennerlein.name>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: xbox one live api
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Requires-Dist: ecdsa
|
|
23
|
+
Requires-Dist: httpx
|
|
24
|
+
Requires-Dist: ms-cv
|
|
25
|
+
Requires-Dist: pydantic==2.*
|
|
26
|
+
Provides-Extra: cli
|
|
27
|
+
Requires-Dist: platformdirs>=4.5.0; extra == 'cli'
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# python-xbox
|
|
31
|
+
|
|
32
|
+
[](https://pypi.python.org/pypi/python-xbox/)
|
|
33
|
+
[](https://github.com/tr4nt0r/python-xbox/actions/workflows/build.yml)
|
|
34
|
+

|
|
35
|
+
[](https://www.buymeacoffee.com/tr4nt0r)
|
|
36
|
+
[](https://github.com/sponsors/tr4nt0r)
|
|
37
|
+
|
|
38
|
+
python-xbox is a python library to authenticate with Xbox Network via your Microsoft Account and provides Xbox related Web-API.
|
|
39
|
+
|
|
40
|
+
Authentication is supported via OAuth2.
|
|
41
|
+
|
|
42
|
+
- Register a new application in [Azure AD](https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade)
|
|
43
|
+
- Name your app
|
|
44
|
+
- Select "Personal Microsoft accounts only" under supported account types
|
|
45
|
+
- Add <http://localhost/auth/callback> as a Redirect URI of type "Web"
|
|
46
|
+
- Copy your Application (client) ID for later use
|
|
47
|
+
- On the App Page, navigate to "Certificates & secrets"
|
|
48
|
+
- Generate a new client secret and save for later use
|
|
49
|
+
|
|
50
|
+
## Dependencies
|
|
51
|
+
|
|
52
|
+
- Python >= 3.11
|
|
53
|
+
|
|
54
|
+
## How to use
|
|
55
|
+
|
|
56
|
+
### Install
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install python-xbox
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Authentication
|
|
63
|
+
|
|
64
|
+
> [!NOTE]
|
|
65
|
+
> You must use non child account (> 18 years old)
|
|
66
|
+
|
|
67
|
+
Token save location: If tokenfile is not provided via cmdline, fallback of `<platformdirs.user_data_dir>/tokens.json` is used as save-location
|
|
68
|
+
|
|
69
|
+
Specifically:
|
|
70
|
+
|
|
71
|
+
Windows: `C:\\Users\\<username>\\AppData\\Local\\OpenXbox\\xbox`
|
|
72
|
+
|
|
73
|
+
Mac OSX: `/Users/<username>/Library/Application Support/xbox/tokens.json`
|
|
74
|
+
|
|
75
|
+
Linux: `/home/<username>/.local/share/xbox`
|
|
76
|
+
|
|
77
|
+
For more information, see: <https://pypi.org/project/platformdirs> and module: `python-xbox.scripts.constants`
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
xbox-authenticate --client-id <client-id> --client-secret <client-secret>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Example: Search Xbox Live via cmdline tool
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Search Xbox One Catalog
|
|
87
|
+
xbox-searchlive "Some game title"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
API usage
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
import asyncio
|
|
94
|
+
import sys
|
|
95
|
+
|
|
96
|
+
from httpx import HTTPStatusError
|
|
97
|
+
|
|
98
|
+
from pythonxbox.api.client import XboxLiveClient
|
|
99
|
+
from pythonxbox.authentication.manager import AuthenticationManager
|
|
100
|
+
from pythonxbox.authentication.models import OAuth2TokenResponse
|
|
101
|
+
from pythonxbox.common.signed_session import SignedSession
|
|
102
|
+
from pythonxbox.scripts import CLIENT_ID, CLIENT_SECRET, TOKENS_FILE
|
|
103
|
+
|
|
104
|
+
"""
|
|
105
|
+
This uses the global default client identification by OpenXbox
|
|
106
|
+
You can supply your own parameters here if you are permitted to create
|
|
107
|
+
new Microsoft OAuth Apps and know what you are doing
|
|
108
|
+
"""
|
|
109
|
+
client_id = CLIENT_ID
|
|
110
|
+
client_secret = CLIENT_SECRET
|
|
111
|
+
tokens_file = TOKENS_FILE
|
|
112
|
+
|
|
113
|
+
"""
|
|
114
|
+
For doing authentication, see pythonxbox/scripts/authenticate.py
|
|
115
|
+
"""
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
async def async_main():
|
|
119
|
+
# Create a HTTP client session
|
|
120
|
+
async with SignedSession() as session:
|
|
121
|
+
"""
|
|
122
|
+
Initialize with global OAUTH parameters from above
|
|
123
|
+
"""
|
|
124
|
+
auth_mgr = AuthenticationManager(session, client_id, client_secret, "")
|
|
125
|
+
|
|
126
|
+
"""
|
|
127
|
+
Read in tokens that you received from the `xbox-authenticate`-script previously
|
|
128
|
+
See `pythonxbox/scripts/authenticate.py`
|
|
129
|
+
"""
|
|
130
|
+
try:
|
|
131
|
+
with open(tokens_file) as f:
|
|
132
|
+
tokens = f.read()
|
|
133
|
+
# Assign gathered tokens
|
|
134
|
+
auth_mgr.oauth = OAuth2TokenResponse.model_validate_json(tokens)
|
|
135
|
+
except FileNotFoundError as e:
|
|
136
|
+
print(
|
|
137
|
+
f"File {tokens_file} isn`t found or it doesn`t contain tokens! err={e}"
|
|
138
|
+
)
|
|
139
|
+
print("Authorizing via OAUTH")
|
|
140
|
+
url = auth_mgr.generate_authorization_url()
|
|
141
|
+
print(f"Auth via URL: {url}")
|
|
142
|
+
authorization_code = input("Enter authorization code> ")
|
|
143
|
+
tokens = await auth_mgr.request_oauth_token(authorization_code)
|
|
144
|
+
auth_mgr.oauth = tokens
|
|
145
|
+
|
|
146
|
+
"""
|
|
147
|
+
Refresh tokens, just in case
|
|
148
|
+
You could also manually check the token lifetimes and just refresh them
|
|
149
|
+
if they are close to expiry
|
|
150
|
+
"""
|
|
151
|
+
try:
|
|
152
|
+
await auth_mgr.refresh_tokens()
|
|
153
|
+
except HTTPStatusError as e:
|
|
154
|
+
print(
|
|
155
|
+
f"""
|
|
156
|
+
Could not refresh tokens from {tokens_file}, err={e}\n
|
|
157
|
+
You might have to delete the tokens file and re-authenticate
|
|
158
|
+
if refresh token is expired
|
|
159
|
+
"""
|
|
160
|
+
)
|
|
161
|
+
sys.exit(-1)
|
|
162
|
+
|
|
163
|
+
# Save the refreshed/updated tokens
|
|
164
|
+
with open(tokens_file, mode="w") as f:
|
|
165
|
+
f.write(auth_mgr.oauth.json())
|
|
166
|
+
print(f"Refreshed tokens in {tokens_file}!")
|
|
167
|
+
|
|
168
|
+
"""
|
|
169
|
+
Construct the Xbox API client from AuthenticationManager instance
|
|
170
|
+
"""
|
|
171
|
+
xbl_client = XboxLiveClient(auth_mgr)
|
|
172
|
+
|
|
173
|
+
"""
|
|
174
|
+
Some example API calls
|
|
175
|
+
"""
|
|
176
|
+
# Get friendslist
|
|
177
|
+
friendslist = await xbl_client.people.get_friends_own()
|
|
178
|
+
print(f"Your friends: {friendslist}\n")
|
|
179
|
+
|
|
180
|
+
# Get presence status (by list of XUID)
|
|
181
|
+
presence = await xbl_client.presence.get_presence_batch(
|
|
182
|
+
["2533274794093122", "2533274807551369"]
|
|
183
|
+
)
|
|
184
|
+
print(f"Statuses of some random players by XUID: {presence}\n")
|
|
185
|
+
|
|
186
|
+
# Get messages
|
|
187
|
+
messages = await xbl_client.message.get_inbox()
|
|
188
|
+
print(f"Your messages: {messages}\n")
|
|
189
|
+
|
|
190
|
+
# Get profile by GT
|
|
191
|
+
profile = await xbl_client.profile.get_profile_by_gamertag("SomeGamertag")
|
|
192
|
+
print(f"Profile under SomeGamertag gamer tag: {profile}\n")
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
asyncio.run(async_main())
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Contribute
|
|
199
|
+
|
|
200
|
+
- Report bugs/suggest features
|
|
201
|
+
- Add/update docs
|
|
202
|
+
- Add additional xbox live endpoints
|
|
203
|
+
|
|
204
|
+
## Credits
|
|
205
|
+
|
|
206
|
+
This library is derived from [xbox-webapi](https://github.com/OpenXbox/xbox-webapi-python) library from the [OpenXbox](https://github.com/openxbox) project
|
|
207
|
+
The authentication code is based on [joealcorn/xbox](https://github.com/joealcorn/xbox)
|
|
208
|
+
|
|
209
|
+
Informations on endpoints gathered from:
|
|
210
|
+
|
|
211
|
+
- [XboxLive REST Reference](https://docs.microsoft.com/en-us/windows/uwp/xbox-live/xbox-live-rest/atoc-xboxlivews-reference)
|
|
212
|
+
- [XboxLiveTraceAnalyzer APIMap](https://github.com/Microsoft/xbox-live-trace-analyzer/blob/master/Source/XboxLiveTraceAnalyzer.APIMap.csv)
|
|
213
|
+
- [Xbox Live Service API](https://github.com/Microsoft/xbox-live-api)
|
|
214
|
+
|
|
215
|
+
## Disclaimer
|
|
216
|
+
|
|
217
|
+
Xbox, Xbox One, Smartglass and Xbox Live are trademarks of Microsoft Corporation. Team OpenXbox is in no way endorsed by or affiliated with Microsoft Corporation, or any associated subsidiaries, logos or trademarks.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
pythonxbox/__init__.py,sha256=LPdRHxT1lTECd7TwCZ7_ph8OOTMBcaIZJDw1ApvAQNU,91
|
|
2
|
+
pythonxbox/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
pythonxbox/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
pythonxbox/api/client.py,sha256=ZPWWjF8si4knZn4kZR1Cb7E2Nb-6x_cLX_hGP5M9X2s,5792
|
|
5
|
+
pythonxbox/api/language.py,sha256=fOmdHD9iIeosM0ePDR4d4veWm1uLujS2gNAyJw4kL9s,3608
|
|
6
|
+
pythonxbox/api/provider/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
pythonxbox/api/provider/baseprovider.py,sha256=Do8Si5cCi8asFk2dEnk3wbbfX0FQ4aevK3FP57JigOw,425
|
|
8
|
+
pythonxbox/api/provider/ratelimitedprovider.py,sha256=BQvLvxGKYAs-hMqEQXDAENN9-aB6LI_XtskS4H_M8s8,3151
|
|
9
|
+
pythonxbox/api/provider/account/__init__.py,sha256=XuErLJye-PMIgHKLK32IMHPq5JFDFN7GhsgbtR-QUuA,2289
|
|
10
|
+
pythonxbox/api/provider/account/models.py,sha256=noWqiSMBLJukNN5g3AHjieuO9el8dDbuDDrXQpmpTQc,197
|
|
11
|
+
pythonxbox/api/provider/achievements/__init__.py,sha256=Hw1nGwqwxzWHM-71Y9LweWdY9IgVhjpsecVCTOwEJwQ,5296
|
|
12
|
+
pythonxbox/api/provider/achievements/models.py,sha256=fEmynni9sxtyZQY3cmhAxC40BGEyfDWhja-IqUZ7paI,2661
|
|
13
|
+
pythonxbox/api/provider/catalog/__init__.py,sha256=gHyBgFrw7tXF4itJJDk4fYkv2GWq0YmyBk43OwoQCXc,2745
|
|
14
|
+
pythonxbox/api/provider/catalog/const.py,sha256=A-1AuA_GxukEYskunzl1KOBDd-D6EueACknR4zx_ThY,462
|
|
15
|
+
pythonxbox/api/provider/catalog/models.py,sha256=2E4vwRGkWRL0EEaQGgxZmME4fXhQjbcbCdCxgGu1mk0,12597
|
|
16
|
+
pythonxbox/api/provider/cqs/__init__.py,sha256=8lx5KxTccs-Jv_xBIhEEdPDmz098mi49hVTPGhhnyno,2666
|
|
17
|
+
pythonxbox/api/provider/cqs/models.py,sha256=2vywdEzLJr0WShHK83_9fTbjkPTLNQjUuXVG1vzraVQ,1123
|
|
18
|
+
pythonxbox/api/provider/gameclips/__init__.py,sha256=ZNCf-pp5nsNmVFoEmTwp7BLtYGpEEoukidvI4ZOZ_V0,5530
|
|
19
|
+
pythonxbox/api/provider/gameclips/models.py,sha256=bgOJL2TXvIsRnkuFFJi14VLzuv7YTQFuWd1LudsFCWM,1182
|
|
20
|
+
pythonxbox/api/provider/lists/__init__.py,sha256=3f5newFaLS2EUgZmt4Sp1vHL-x3XRYaL88kwptX5jKk,2336
|
|
21
|
+
pythonxbox/api/provider/lists/models.py,sha256=kr_KZZReIzzini-YZpfNJxdLmzRIThYq2yOIIFYzBKs,666
|
|
22
|
+
pythonxbox/api/provider/mediahub/__init__.py,sha256=bY67pw-u1lxhHNUiRx-jN6mJ4Y3wgPKICqRGEv4Kxew,1827
|
|
23
|
+
pythonxbox/api/provider/mediahub/models.py,sha256=0dqaUlDpRZVRLEQcgZIVmGT97Ya6T4ccqermXzwXavo,1863
|
|
24
|
+
pythonxbox/api/provider/message/__init__.py,sha256=PqRPAIa_iHVOjbiBkrbNu3jn4wUtNZusamiHpAUi2n0,4163
|
|
25
|
+
pythonxbox/api/provider/message/models.py,sha256=P1IJblzGUYYPXE04LHSVEUmXeUqm8g5FKrO0jnm9jNE,2026
|
|
26
|
+
pythonxbox/api/provider/people/__init__.py,sha256=YHscpAknxIBMPJeXuuI_eZ0Dx9mqvkKnwxbxpE7ynJk,6496
|
|
27
|
+
pythonxbox/api/provider/people/models.py,sha256=bjS4in0jE-6cVTnPvR8aVFE57KrxIEO_-dUDHWB72l4,6891
|
|
28
|
+
pythonxbox/api/provider/presence/__init__.py,sha256=Gvfh7AY7HE6S_bYmvWfE2Skoa71BNnMediPH6cp2w7s,3285
|
|
29
|
+
pythonxbox/api/provider/presence/models.py,sha256=MkH5Gf0khsm6856ndnYN6WYKfo2Zl-LJX_-GXuQB3jI,1133
|
|
30
|
+
pythonxbox/api/provider/profile/__init__.py,sha256=x71ObWdrFw1VOohf_5b4Kas7-uSIHAs17Ha9Y4jI1Z8,4931
|
|
31
|
+
pythonxbox/api/provider/profile/models.py,sha256=XHirnTYX0gBpvvOSygi1Uw19JkO2B78PWM__wNj4Yxo,1222
|
|
32
|
+
pythonxbox/api/provider/screenshots/__init__.py,sha256=4t4hwjGCP80Hdb8R63eRy4l6uEk-cGMUZ7IWChqTLLI,5720
|
|
33
|
+
pythonxbox/api/provider/screenshots/models.py,sha256=fLmliYx8yzGAiQlsnujCldHKDKjvUGYxEwUz_CUxWow,1176
|
|
34
|
+
pythonxbox/api/provider/smartglass/__init__.py,sha256=TnwBhUZ_wgfHeSkaTOFvyBldLCdEgAFknbH6Sdogpig,11516
|
|
35
|
+
pythonxbox/api/provider/smartglass/models.py,sha256=wgAfH98xnjPGjXKtr7a5NKZSkbjr4F0XvHOcqtQph5g,4264
|
|
36
|
+
pythonxbox/api/provider/titlehub/__init__.py,sha256=uFSFK6huMHfeG_qlHTnsDYfByNyMM_m3XlGUm8obobU,4602
|
|
37
|
+
pythonxbox/api/provider/titlehub/models.py,sha256=zQF3a87lMGpogt6MQhWwg-mTSzYr5PKGnE28Oj8jXD4,2556
|
|
38
|
+
pythonxbox/api/provider/usersearch/__init__.py,sha256=Zn764HCku9_Nq36rkJPVcbx2Xacz4aaTiITTKDIYbz0,912
|
|
39
|
+
pythonxbox/api/provider/usersearch/models.py,sha256=C2l8nJJpaHOwXLiUMpnndbhs_MQYiMQdEkWk0JxPbuc,307
|
|
40
|
+
pythonxbox/api/provider/userstats/__init__.py,sha256=rVh7l_FcMQXXHtEeGJK-IwCdGm8KPsHdTUWhxxdHrkI,5324
|
|
41
|
+
pythonxbox/api/provider/userstats/models.py,sha256=sw9lU0sAPIjg-v943y5c0JYGEIYiuD04rN9mrtXDrds,1001
|
|
42
|
+
pythonxbox/authentication/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
43
|
+
pythonxbox/authentication/manager.py,sha256=pZuk7UvwqALpgj_lWwZtk-dQFpn6JhYWjuwwrWv-HHs,5709
|
|
44
|
+
pythonxbox/authentication/models.py,sha256=299uE2A7xv2ZF1eBWYcg8CPh_xRV9aQD9_viTOfDUnw,3510
|
|
45
|
+
pythonxbox/authentication/xal.py,sha256=hucd4mCfg7_58PJ4rVH25X5RMEMhWU9ZFFFKK77lAgk,11563
|
|
46
|
+
pythonxbox/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
47
|
+
pythonxbox/common/exceptions.py,sha256=9ZliKLYYXxk-7Qn2Kzu7sDplSEFiJUF--9SaMcjD1No,1587
|
|
48
|
+
pythonxbox/common/filetimes.py,sha256=bk27l4KUhBRJwnCF_p0wrJvKdBMMruXGf15g4lUNNUU,3334
|
|
49
|
+
pythonxbox/common/models.py,sha256=wmLXnFlZ1YoyiM-c6dnwzSSulfTzuin0D72_sQ_jN6I,852
|
|
50
|
+
pythonxbox/common/request_signer.py,sha256=5pQBGkXKIrxx89Au-sDOf3VqhntVyc2DGZvVjZpdwTc,5518
|
|
51
|
+
pythonxbox/common/signed_session.py,sha256=TMnWAe7pX5z9Pa7A5oQNjnoI83PhNo0OpRk_hGwCD-s,1886
|
|
52
|
+
pythonxbox/common/ratelimits/__init__.py,sha256=J7NHAfNbab7g_zsvD2cRrKpVzZAkHD6B7QH9iGwT9bc,10126
|
|
53
|
+
pythonxbox/common/ratelimits/models.py,sha256=UmvQGtLd_J33Idx3OlR7QepvhhGSUnKVIg1CvswNCho,358
|
|
54
|
+
pythonxbox/scripts/__init__.py,sha256=Cii7pu86DZq6bZjDFnztxz9Cz1UdNOOeveZf_XcQSbU,455
|
|
55
|
+
pythonxbox/scripts/authenticate.py,sha256=OT5eFtZZ3dN-XWHtMo9ciMJG8NhJCgXVItLBpqNqn-U,5042
|
|
56
|
+
pythonxbox/scripts/change_gamertag.py,sha256=zTvrCRGjUAjRls_9bIoc11UGlAfg9UVhYknqYQtvGRs,3319
|
|
57
|
+
pythonxbox/scripts/friends.py,sha256=TmcpLJ3FJaNMCNc5gVyxabgnlFd2hS_tBYautx1xD6s,2139
|
|
58
|
+
pythonxbox/scripts/search.py,sha256=DusjFE4q10sHVrbdE44kBw0xvv6i_muJqZLCcnO6zzc,1074
|
|
59
|
+
pythonxbox/scripts/xal.py,sha256=G9_ABhUPPwEEroE2NVXmUb3Gx50wl9J2yNhTAKv4hI0,2960
|
|
60
|
+
python_xbox-0.1.0.dist-info/METADATA,sha256=BgVizVDPfU8oWQBCpwRKdVezb11vSuDdT1M0iiOBnfg,7702
|
|
61
|
+
python_xbox-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
62
|
+
python_xbox-0.1.0.dist-info/entry_points.txt,sha256=9k_ot4_yHrDQTbXDWZPCHtn7S_rJLLv5Sw1Vf__TY78,267
|
|
63
|
+
python_xbox-0.1.0.dist-info/licenses/LICENSE,sha256=NylgC1sD9vQJ92ofyOI0lvDYOuvbTyWa-tCSU8KgeeI,1104
|
|
64
|
+
python_xbox-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
[console_scripts]
|
|
2
|
+
xbox-authenticate = pythonxbox.scripts.authenticate:main
|
|
3
|
+
xbox-change-gt = pythonxbox.scripts.change_gamertag:main
|
|
4
|
+
xbox-friends = pythonxbox.scripts.friends:main
|
|
5
|
+
xbox-searchlive = pythonxbox.scripts.search:main
|
|
6
|
+
xbox-xal = pythonxbox.scripts.xal:main
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2025 Manfred Dennerlein Rodelo
|
|
2
|
+
Copyright (c) 2020 - 2025 OpenXbox
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
pythonxbox/__init__.py
ADDED
|
File without changes
|
pythonxbox/api/client.py
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Xbox Live Client
|
|
3
|
+
|
|
4
|
+
Basic factory that stores :class:`XboxLiveLanguage`, User authorization data
|
|
5
|
+
and available `Providers`
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import logging
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
from httpx import Response
|
|
12
|
+
from ms_cv import CorrelationVector
|
|
13
|
+
|
|
14
|
+
from pythonxbox.api.language import DefaultXboxLiveLanguages, XboxLiveLanguage
|
|
15
|
+
from pythonxbox.api.provider.account import AccountProvider
|
|
16
|
+
from pythonxbox.api.provider.achievements import AchievementsProvider
|
|
17
|
+
from pythonxbox.api.provider.catalog import CatalogProvider
|
|
18
|
+
from pythonxbox.api.provider.cqs import CQSProvider
|
|
19
|
+
from pythonxbox.api.provider.gameclips import GameclipProvider
|
|
20
|
+
from pythonxbox.api.provider.lists import ListsProvider
|
|
21
|
+
from pythonxbox.api.provider.mediahub import MediahubProvider
|
|
22
|
+
from pythonxbox.api.provider.message import MessageProvider
|
|
23
|
+
from pythonxbox.api.provider.people import PeopleProvider
|
|
24
|
+
from pythonxbox.api.provider.presence import PresenceProvider
|
|
25
|
+
from pythonxbox.api.provider.profile import ProfileProvider
|
|
26
|
+
from pythonxbox.api.provider.screenshots import ScreenshotsProvider
|
|
27
|
+
from pythonxbox.api.provider.smartglass import SmartglassProvider
|
|
28
|
+
from pythonxbox.api.provider.titlehub import TitlehubProvider
|
|
29
|
+
from pythonxbox.api.provider.usersearch import UserSearchProvider
|
|
30
|
+
from pythonxbox.api.provider.userstats import UserStatsProvider
|
|
31
|
+
from pythonxbox.authentication.manager import AuthenticationManager
|
|
32
|
+
from pythonxbox.common.exceptions import RateLimitExceededException
|
|
33
|
+
from pythonxbox.common.ratelimits import RateLimit
|
|
34
|
+
|
|
35
|
+
log = logging.getLogger("xbox.api")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class Session:
|
|
39
|
+
def __init__(self, auth_mgr: AuthenticationManager) -> None:
|
|
40
|
+
self._auth_mgr = auth_mgr
|
|
41
|
+
self._cv = CorrelationVector()
|
|
42
|
+
|
|
43
|
+
async def request(
|
|
44
|
+
self,
|
|
45
|
+
method: str,
|
|
46
|
+
url: str,
|
|
47
|
+
include_auth: bool = True,
|
|
48
|
+
include_cv: bool = True,
|
|
49
|
+
**kwargs: Any,
|
|
50
|
+
) -> Response:
|
|
51
|
+
"""Proxy Request and add Auth/CV headers."""
|
|
52
|
+
headers = kwargs.pop("headers", {})
|
|
53
|
+
params = kwargs.pop("params", None)
|
|
54
|
+
data = kwargs.pop("data", None)
|
|
55
|
+
|
|
56
|
+
# Extra, user supplied values
|
|
57
|
+
extra_headers = kwargs.pop("extra_headers", None)
|
|
58
|
+
extra_params = kwargs.pop("extra_params", None)
|
|
59
|
+
extra_data = kwargs.pop("extra_data", None)
|
|
60
|
+
|
|
61
|
+
# Rate limit object
|
|
62
|
+
rate_limits: RateLimit = kwargs.pop("rate_limits", None)
|
|
63
|
+
|
|
64
|
+
if include_auth:
|
|
65
|
+
# Ensure tokens valid
|
|
66
|
+
await self._auth_mgr.refresh_tokens()
|
|
67
|
+
# Set auth header
|
|
68
|
+
headers["Authorization"] = (
|
|
69
|
+
self._auth_mgr.xsts_token.authorization_header_value
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
if include_cv:
|
|
73
|
+
headers["MS-CV"] = self._cv.increment()
|
|
74
|
+
|
|
75
|
+
# Extend with optionally supplied values
|
|
76
|
+
if extra_headers:
|
|
77
|
+
headers.update(extra_headers)
|
|
78
|
+
if extra_params:
|
|
79
|
+
# query parameters
|
|
80
|
+
params = params or {}
|
|
81
|
+
params.update(extra_params)
|
|
82
|
+
if extra_data:
|
|
83
|
+
# form encoded post data
|
|
84
|
+
data = data or {}
|
|
85
|
+
data.update(extra_data)
|
|
86
|
+
|
|
87
|
+
if rate_limits:
|
|
88
|
+
# Check if rate limits have been exceeded for this endpoint
|
|
89
|
+
if rate_limits.is_exceeded():
|
|
90
|
+
raise RateLimitExceededException("Rate limit exceeded", rate_limits)
|
|
91
|
+
|
|
92
|
+
response = await self._auth_mgr.session.request(
|
|
93
|
+
method, url, **kwargs, headers=headers, params=params, data=data
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
if rate_limits:
|
|
97
|
+
rate_limits.increment()
|
|
98
|
+
|
|
99
|
+
return response
|
|
100
|
+
|
|
101
|
+
async def get(self, url: str, **kwargs: Any) -> Response:
|
|
102
|
+
return await self.request("GET", url, **kwargs)
|
|
103
|
+
|
|
104
|
+
async def options(self, url: str, **kwargs: Any) -> Response:
|
|
105
|
+
return await self.request("OPTIONS", url, **kwargs)
|
|
106
|
+
|
|
107
|
+
async def head(self, url: str, **kwargs: Any) -> Response:
|
|
108
|
+
return await self.request("HEAD", url, **kwargs)
|
|
109
|
+
|
|
110
|
+
async def post(self, url: str, **kwargs: Any) -> Response:
|
|
111
|
+
return await self.request("POST", url, **kwargs)
|
|
112
|
+
|
|
113
|
+
async def put(self, url: str, **kwargs: Any) -> Response:
|
|
114
|
+
return await self.request("PUT", url, **kwargs)
|
|
115
|
+
|
|
116
|
+
async def patch(self, url: str, **kwargs: Any) -> Response:
|
|
117
|
+
return await self.request("PATCH", url, **kwargs)
|
|
118
|
+
|
|
119
|
+
async def delete(self, url: str, **kwargs: Any) -> Response:
|
|
120
|
+
return await self.request("DELETE", url, **kwargs)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class XboxLiveClient:
|
|
124
|
+
def __init__(
|
|
125
|
+
self,
|
|
126
|
+
auth_mgr: AuthenticationManager,
|
|
127
|
+
language: XboxLiveLanguage = DefaultXboxLiveLanguages.United_States,
|
|
128
|
+
) -> None:
|
|
129
|
+
self._auth_mgr = auth_mgr
|
|
130
|
+
self.session = Session(auth_mgr)
|
|
131
|
+
self._language = language
|
|
132
|
+
|
|
133
|
+
self.cqs = CQSProvider(self)
|
|
134
|
+
self.lists = ListsProvider(self)
|
|
135
|
+
self.profile = ProfileProvider(self)
|
|
136
|
+
self.achievements = AchievementsProvider(self)
|
|
137
|
+
self.usersearch = UserSearchProvider(self)
|
|
138
|
+
self.gameclips = GameclipProvider(self)
|
|
139
|
+
self.people = PeopleProvider(self)
|
|
140
|
+
self.presence = PresenceProvider(self)
|
|
141
|
+
self.mediahub = MediahubProvider(self)
|
|
142
|
+
self.message = MessageProvider(self)
|
|
143
|
+
self.userstats = UserStatsProvider(self)
|
|
144
|
+
self.screenshots = ScreenshotsProvider(self)
|
|
145
|
+
self.titlehub = TitlehubProvider(self)
|
|
146
|
+
self.account = AccountProvider(self)
|
|
147
|
+
self.catalog = CatalogProvider(self)
|
|
148
|
+
self.smartglass = SmartglassProvider(self)
|
|
149
|
+
|
|
150
|
+
@property
|
|
151
|
+
def xuid(self) -> str:
|
|
152
|
+
"""
|
|
153
|
+
Gets the Xbox User ID
|
|
154
|
+
|
|
155
|
+
Returns: Xbox user Id
|
|
156
|
+
"""
|
|
157
|
+
return self._auth_mgr.xsts_token.xuid
|
|
158
|
+
|
|
159
|
+
@property
|
|
160
|
+
def language(self) -> XboxLiveLanguage:
|
|
161
|
+
"""
|
|
162
|
+
Gets the active Xbox Live Language
|
|
163
|
+
|
|
164
|
+
Returns: Active Xbox Live language
|
|
165
|
+
"""
|
|
166
|
+
return self._language
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Language definitions
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class XboxLiveLanguage:
|
|
7
|
+
def __init__(
|
|
8
|
+
self,
|
|
9
|
+
name: str,
|
|
10
|
+
short_id: str,
|
|
11
|
+
identifier: str,
|
|
12
|
+
locale: str,
|
|
13
|
+
) -> None:
|
|
14
|
+
"""
|
|
15
|
+
Initialize a new instance of :class:`XboxLiveLanguage`
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
name (str): Full name describing the language / country
|
|
19
|
+
short_id (str): Short Id (e.g. "AT" for Austria)
|
|
20
|
+
identifier (str): Identifier (e.g. "de_AT" for Austria)
|
|
21
|
+
locale (str): Locale (e.g. "de-AT" for Austria)
|
|
22
|
+
"""
|
|
23
|
+
self.name = name
|
|
24
|
+
self.short_id = short_id
|
|
25
|
+
self.identifier = identifier
|
|
26
|
+
self.locale = locale
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class DefaultXboxLiveLanguages:
|
|
30
|
+
"""
|
|
31
|
+
Collection of locales compatible with XBL
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
Argentina = XboxLiveLanguage("Argentina", "AR", "es_AR", "es-AR")
|
|
35
|
+
Australia = XboxLiveLanguage("Australia", "AU", "en_AU", "en-AU")
|
|
36
|
+
Austria = XboxLiveLanguage("Austria", "AT", "de_AT", "de-AT")
|
|
37
|
+
Belgium = XboxLiveLanguage("Belgium", "BE", "fr_BE", "fr-BE")
|
|
38
|
+
Belgium_NL = XboxLiveLanguage("Belgium (NL)", "NL", "nl_BE", "nl-BE")
|
|
39
|
+
Brazil = XboxLiveLanguage("Brazil", "BR", "pt_BR", "pt-BR")
|
|
40
|
+
Canada = XboxLiveLanguage("Canada", "CA", "en_CA", "en-CA")
|
|
41
|
+
Canada_FR = XboxLiveLanguage("Canada (FR)", "CA", "fr_CA", "fr-CA")
|
|
42
|
+
Czech_Republic = XboxLiveLanguage("Czech Republic", "CZ", "en_CZ", "en-CZ")
|
|
43
|
+
Denmark = XboxLiveLanguage("Denmark", "DK", "da_DK", "da-DK")
|
|
44
|
+
Finland = XboxLiveLanguage("Finland", "FI", "fi_FI", "fi-FI")
|
|
45
|
+
France = XboxLiveLanguage("France", "FR", "fr_FR", "fr-FR")
|
|
46
|
+
Germany = XboxLiveLanguage("Germany", "DE", "de_DE", "de-DE")
|
|
47
|
+
Greece = XboxLiveLanguage("Greece", "GR", "en_GR", "en-GR")
|
|
48
|
+
Hong_Kong = XboxLiveLanguage("Hong Kong", "HK", "en_HK", "en-HK")
|
|
49
|
+
Hungary = XboxLiveLanguage("Hungary", "HU", "en_HU", "en-HU")
|
|
50
|
+
India = XboxLiveLanguage("India", "IN", "en_IN", "en-IN")
|
|
51
|
+
Great_Britain = XboxLiveLanguage("Great Britain", "GB", "en_GB", "en-GB")
|
|
52
|
+
Israel = XboxLiveLanguage("Israel", "IL", "en_IL", "en-IL")
|
|
53
|
+
Italy = XboxLiveLanguage("Italy", "IT", "it_IT", "it-IT")
|
|
54
|
+
Japan = XboxLiveLanguage("Japan", "JP", "ja_JP", "ja-JP")
|
|
55
|
+
Mexico = XboxLiveLanguage("Mexico", "MX", "es_MX", "es-MX")
|
|
56
|
+
Chile = XboxLiveLanguage("Chile", "CL", "es_CL", "es-CL")
|
|
57
|
+
Colombia = XboxLiveLanguage("Colombia", "CO", "es_CO", "es-CO")
|
|
58
|
+
Netherlands = XboxLiveLanguage("Netherlands", "NL", "nl_NL", "nl-NL")
|
|
59
|
+
New_Zealand = XboxLiveLanguage("New Zealand", "NZ", "en_NZ", "en-NZ")
|
|
60
|
+
Norway = XboxLiveLanguage("Norway", "NO", "nb_NO", "nb-NO")
|
|
61
|
+
Poland = XboxLiveLanguage("Poland", "PL", "pl_PL", "pl-PL")
|
|
62
|
+
Portugal = XboxLiveLanguage("Portugal", "PT", "pt_PT", "pt-PT")
|
|
63
|
+
Russia = XboxLiveLanguage("Russia", "RU", "ru_RU", "ru-RU")
|
|
64
|
+
Saudi_Arabia = XboxLiveLanguage("Saudi Arabia", "SA", "en_SA", "en-SA")
|
|
65
|
+
Singapore = XboxLiveLanguage("Singapore", "SG", "en_SG", "en-SG")
|
|
66
|
+
Slovakia = XboxLiveLanguage("Slovakia", "SK", "en_SK", "en-SK")
|
|
67
|
+
South_Africa = XboxLiveLanguage("South Afrida", "ZA", "en_ZA", "en-ZA")
|
|
68
|
+
Korea = XboxLiveLanguage("Korea", "KR", "ko_KR", "ko-KR")
|
|
69
|
+
Spain = XboxLiveLanguage("Spain", "ES", "es_ES", "es-ES")
|
|
70
|
+
Switzerland = XboxLiveLanguage("Switzerland", "CH", "de_CH", "de-CH")
|
|
71
|
+
Switzerland_FR = XboxLiveLanguage("Switzerland (FR)", "CH", "fr_CH", "fr-CH")
|
|
72
|
+
United_Arab_Emirates = XboxLiveLanguage(
|
|
73
|
+
"United Arab Emirates", "AE", "en_AE", "en-AE"
|
|
74
|
+
)
|
|
75
|
+
United_States = XboxLiveLanguage("United States", "US", "en_US", "en-US")
|
|
76
|
+
Ireland = XboxLiveLanguage("Ireland", "IE", "en_IE", "en-IE")
|
|
File without changes
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
from pythonxbox.api.provider.account.models import (
|
|
2
|
+
ChangeGamertagResult,
|
|
3
|
+
ClaimGamertagResult,
|
|
4
|
+
)
|
|
5
|
+
from pythonxbox.api.provider.baseprovider import BaseProvider
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class AccountProvider(BaseProvider):
|
|
9
|
+
BASE_URL_USER_MGT = "https://user.mgt.xboxlive.com"
|
|
10
|
+
BASE_URL_ACCOUNT = "https://accounts.xboxlive.com"
|
|
11
|
+
|
|
12
|
+
HEADERS_USER_MGT = {"x-xbl-contract-version": "1"}
|
|
13
|
+
HEADERS_ACCOUNT = {"x-xbl-contract-version": "2"}
|
|
14
|
+
|
|
15
|
+
async def claim_gamertag(
|
|
16
|
+
self, xuid: str, gamertag: str, **kwargs
|
|
17
|
+
) -> ClaimGamertagResult:
|
|
18
|
+
"""
|
|
19
|
+
Claim gamertag
|
|
20
|
+
|
|
21
|
+
XLE error codes:
|
|
22
|
+
400 - Bad API request
|
|
23
|
+
401 - Unauthorized
|
|
24
|
+
409 - Gamertag unavailable
|
|
25
|
+
429 - Too many requests
|
|
26
|
+
200 - Gamertag available
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
xuid (int): Your xuid as integer
|
|
30
|
+
gamertag (str): Desired gamertag
|
|
31
|
+
|
|
32
|
+
Returns: ClaimGamertagResult
|
|
33
|
+
"""
|
|
34
|
+
url = self.BASE_URL_USER_MGT + "/gamertags/reserve"
|
|
35
|
+
post_data = {"Gamertag": gamertag, "ReservationId": str(xuid)}
|
|
36
|
+
resp = await self.client.session.post(
|
|
37
|
+
url, json=post_data, headers=self.HEADERS_USER_MGT, **kwargs
|
|
38
|
+
)
|
|
39
|
+
try:
|
|
40
|
+
return ClaimGamertagResult(resp.status_code)
|
|
41
|
+
except ValueError:
|
|
42
|
+
resp.raise_for_status()
|
|
43
|
+
|
|
44
|
+
async def change_gamertag(
|
|
45
|
+
self, xuid: str, gamertag: str, preview: bool = False, **kwargs
|
|
46
|
+
) -> ChangeGamertagResult:
|
|
47
|
+
"""
|
|
48
|
+
Change your gamertag.
|
|
49
|
+
|
|
50
|
+
XLE error codes:
|
|
51
|
+
200 - success
|
|
52
|
+
1020 - No free gamertag changes available
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
xuid (int): Your Xuid as integer
|
|
56
|
+
gamertag (str): Desired gamertag name
|
|
57
|
+
preview (bool): Preview the change
|
|
58
|
+
|
|
59
|
+
Returns: ChangeGamertagResult
|
|
60
|
+
"""
|
|
61
|
+
url = self.BASE_URL_ACCOUNT + "/users/current/profile/gamertag"
|
|
62
|
+
post_data = {
|
|
63
|
+
"gamertag": gamertag,
|
|
64
|
+
"preview": preview,
|
|
65
|
+
"reservationId": int(xuid),
|
|
66
|
+
}
|
|
67
|
+
resp = await self.client.session.post(
|
|
68
|
+
url, json=post_data, headers=self.HEADERS_ACCOUNT, **kwargs
|
|
69
|
+
)
|
|
70
|
+
try:
|
|
71
|
+
return ChangeGamertagResult(resp.status_code)
|
|
72
|
+
except ValueError:
|
|
73
|
+
resp.raise_for_status()
|