python-xbox 0.1.0rc0__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.0rc0.dist-info/METADATA +213 -0
- python_xbox-0.1.0rc0.dist-info/RECORD +63 -0
- python_xbox-0.1.0rc0.dist-info/WHEEL +4 -0
- python_xbox-0.1.0rc0.dist-info/entry_points.txt +6 -0
- python_xbox-0.1.0rc0.dist-info/licenses/LICENSE +19 -0
- webapi/__init__.py +4 -0
- webapi/api/__init__.py +0 -0
- webapi/api/client.py +166 -0
- webapi/api/language.py +70 -0
- webapi/api/provider/__init__.py +0 -0
- webapi/api/provider/account/__init__.py +71 -0
- webapi/api/provider/account/models.py +11 -0
- webapi/api/provider/achievements/__init__.py +164 -0
- webapi/api/provider/achievements/models.py +133 -0
- webapi/api/provider/baseprovider.py +16 -0
- webapi/api/provider/catalog/__init__.py +88 -0
- webapi/api/provider/catalog/const.py +15 -0
- webapi/api/provider/catalog/models.py +428 -0
- webapi/api/provider/cqs/__init__.py +85 -0
- webapi/api/provider/cqs/models.py +59 -0
- webapi/api/provider/gameclips/__init__.py +167 -0
- webapi/api/provider/gameclips/models.py +59 -0
- webapi/api/provider/lists/__init__.py +71 -0
- webapi/api/provider/lists/models.py +35 -0
- webapi/api/provider/mediahub/__init__.py +64 -0
- webapi/api/provider/mediahub/models.py +84 -0
- webapi/api/provider/message/__init__.py +135 -0
- webapi/api/provider/message/models.py +96 -0
- webapi/api/provider/people/__init__.py +193 -0
- webapi/api/provider/people/models.py +252 -0
- webapi/api/provider/presence/__init__.py +112 -0
- webapi/api/provider/presence/models.py +54 -0
- webapi/api/provider/profile/__init__.py +142 -0
- webapi/api/provider/profile/models.py +48 -0
- webapi/api/provider/ratelimitedprovider.py +77 -0
- webapi/api/provider/screenshots/__init__.py +167 -0
- webapi/api/provider/screenshots/models.py +56 -0
- webapi/api/provider/smartglass/__init__.py +399 -0
- webapi/api/provider/smartglass/models.py +187 -0
- webapi/api/provider/titlehub/__init__.py +141 -0
- webapi/api/provider/titlehub/models.py +106 -0
- webapi/api/provider/usersearch/__init__.py +29 -0
- webapi/api/provider/usersearch/models.py +19 -0
- webapi/api/provider/userstats/__init__.py +166 -0
- webapi/api/provider/userstats/models.py +46 -0
- webapi/authentication/__init__.py +0 -0
- webapi/authentication/manager.py +162 -0
- webapi/authentication/models.py +163 -0
- webapi/authentication/xal.py +348 -0
- webapi/common/__init__.py +0 -0
- webapi/common/exceptions.py +57 -0
- webapi/common/filetimes.py +97 -0
- webapi/common/models.py +34 -0
- webapi/common/ratelimits/__init__.py +269 -0
- webapi/common/ratelimits/models.py +23 -0
- webapi/common/request_signer.py +189 -0
- webapi/common/signed_session.py +54 -0
- webapi/scripts/__init__.py +15 -0
- webapi/scripts/authenticate.py +159 -0
- webapi/scripts/change_gamertag.py +111 -0
- webapi/scripts/friends.py +80 -0
- webapi/scripts/search.py +43 -0
- webapi/scripts/xal.py +113 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-xbox
|
|
3
|
+
Version: 0.1.0rc0
|
|
4
|
+
Summary: A library to authenticate with Xbox Network and use their API
|
|
5
|
+
Project-URL: Homepage, https://github.com/tr4nt0r/python-xbox
|
|
6
|
+
Author: OpenXbox
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: xbox one live api
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Requires-Dist: appdirs
|
|
21
|
+
Requires-Dist: ecdsa
|
|
22
|
+
Requires-Dist: httpx
|
|
23
|
+
Requires-Dist: ms-cv
|
|
24
|
+
Requires-Dist: pydantic==2.*
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# Xbox-WebAPI
|
|
28
|
+
|
|
29
|
+
[](https://pypi.python.org/pypi/xbox-webapi/)
|
|
30
|
+
[](http://xbox-webapi-python.readthedocs.io/en/latest/?badge=latest)
|
|
31
|
+
[](https://github.com/OpenXbox/xbox-webapi-python/actions?query=workflow%3Abuild)
|
|
32
|
+
[](https://openxbox.org/discord)
|
|
33
|
+
|
|
34
|
+
Xbox-WebAPI is a python library to authenticate with Xbox Live via your Microsoft Account and provides Xbox related Web-API.
|
|
35
|
+
|
|
36
|
+
Authentication is supported via OAuth2.
|
|
37
|
+
|
|
38
|
+
- Register a new application in [Azure AD](https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade)
|
|
39
|
+
- Name your app
|
|
40
|
+
- Select "Personal Microsoft accounts only" under supported account types
|
|
41
|
+
- Add <http://localhost/auth/callback> as a Redirect URI of type "Web"
|
|
42
|
+
- Copy your Application (client) ID for later use
|
|
43
|
+
- On the App Page, navigate to "Certificates & secrets"
|
|
44
|
+
- Generate a new client secret and save for later use
|
|
45
|
+
|
|
46
|
+
## Dependencies
|
|
47
|
+
|
|
48
|
+
- Python >= 3.8
|
|
49
|
+
|
|
50
|
+
## How to use
|
|
51
|
+
|
|
52
|
+
Install
|
|
53
|
+
|
|
54
|
+
```text
|
|
55
|
+
pip install xbox-webapi
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Authentication
|
|
59
|
+
|
|
60
|
+
**Note: You must use non child account (> 18 years old)**
|
|
61
|
+
|
|
62
|
+
Token save location: If tokenfile is not provided via cmdline, fallback of `<appdirs.user_data_dir>/tokens.json` is used as save-location
|
|
63
|
+
|
|
64
|
+
Specifically:
|
|
65
|
+
|
|
66
|
+
Windows: `C:\\Users\\<username>\\AppData\\Local\\OpenXbox\\xbox`
|
|
67
|
+
|
|
68
|
+
Mac OSX: `/Users/<username>/Library/Application Support/xbox/tokens.json`
|
|
69
|
+
|
|
70
|
+
Linux: `/home/<username>/.local/share/xbox`
|
|
71
|
+
|
|
72
|
+
For more information, see: <https://pypi.org/project/appdirs> and module: `xbox.webapi.scripts.constants`
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
xbox-authenticate --client-id <client-id> --client-secret <client-secret>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Example: Search Xbox Live via cmdline tool
|
|
79
|
+
|
|
80
|
+
```text
|
|
81
|
+
# Search Xbox One Catalog
|
|
82
|
+
xbox-searchlive "Some game title"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
API usage
|
|
86
|
+
|
|
87
|
+
```py
|
|
88
|
+
import asyncio
|
|
89
|
+
import sys
|
|
90
|
+
|
|
91
|
+
from httpx import HTTPStatusError
|
|
92
|
+
|
|
93
|
+
from xbox.webapi.api.client import XboxLiveClient
|
|
94
|
+
from xbox.webapi.authentication.manager import AuthenticationManager
|
|
95
|
+
from xbox.webapi.authentication.models import OAuth2TokenResponse
|
|
96
|
+
from xbox.webapi.common.signed_session import SignedSession
|
|
97
|
+
from xbox.webapi.scripts import CLIENT_ID, CLIENT_SECRET, TOKENS_FILE
|
|
98
|
+
|
|
99
|
+
"""
|
|
100
|
+
This uses the global default client identification by OpenXbox
|
|
101
|
+
You can supply your own parameters here if you are permitted to create
|
|
102
|
+
new Microsoft OAuth Apps and know what you are doing
|
|
103
|
+
"""
|
|
104
|
+
client_id = CLIENT_ID
|
|
105
|
+
client_secret = CLIENT_SECRET
|
|
106
|
+
tokens_file = TOKENS_FILE
|
|
107
|
+
|
|
108
|
+
"""
|
|
109
|
+
For doing authentication, see xbox/webapi/scripts/authenticate.py
|
|
110
|
+
"""
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
async def async_main():
|
|
114
|
+
# Create a HTTP client session
|
|
115
|
+
async with SignedSession() as session:
|
|
116
|
+
"""
|
|
117
|
+
Initialize with global OAUTH parameters from above
|
|
118
|
+
"""
|
|
119
|
+
auth_mgr = AuthenticationManager(session, client_id, client_secret, "")
|
|
120
|
+
|
|
121
|
+
"""
|
|
122
|
+
Read in tokens that you received from the `xbox-authenticate`-script previously
|
|
123
|
+
See `xbox/webapi/scripts/authenticate.py`
|
|
124
|
+
"""
|
|
125
|
+
try:
|
|
126
|
+
with open(tokens_file) as f:
|
|
127
|
+
tokens = f.read()
|
|
128
|
+
# Assign gathered tokens
|
|
129
|
+
auth_mgr.oauth = OAuth2TokenResponse.model_validate_json(tokens)
|
|
130
|
+
except FileNotFoundError as e:
|
|
131
|
+
print(
|
|
132
|
+
f"File {tokens_file} isn`t found or it doesn`t contain tokens! err={e}"
|
|
133
|
+
)
|
|
134
|
+
print("Authorizing via OAUTH")
|
|
135
|
+
url = auth_mgr.generate_authorization_url()
|
|
136
|
+
print(f"Auth via URL: {url}")
|
|
137
|
+
authorization_code = input("Enter authorization code> ")
|
|
138
|
+
tokens = await auth_mgr.request_oauth_token(authorization_code)
|
|
139
|
+
auth_mgr.oauth = tokens
|
|
140
|
+
|
|
141
|
+
"""
|
|
142
|
+
Refresh tokens, just in case
|
|
143
|
+
You could also manually check the token lifetimes and just refresh them
|
|
144
|
+
if they are close to expiry
|
|
145
|
+
"""
|
|
146
|
+
try:
|
|
147
|
+
await auth_mgr.refresh_tokens()
|
|
148
|
+
except HTTPStatusError as e:
|
|
149
|
+
print(
|
|
150
|
+
f"""
|
|
151
|
+
Could not refresh tokens from {tokens_file}, err={e}\n
|
|
152
|
+
You might have to delete the tokens file and re-authenticate
|
|
153
|
+
if refresh token is expired
|
|
154
|
+
"""
|
|
155
|
+
)
|
|
156
|
+
sys.exit(-1)
|
|
157
|
+
|
|
158
|
+
# Save the refreshed/updated tokens
|
|
159
|
+
with open(tokens_file, mode="w") as f:
|
|
160
|
+
f.write(auth_mgr.oauth.json())
|
|
161
|
+
print(f"Refreshed tokens in {tokens_file}!")
|
|
162
|
+
|
|
163
|
+
"""
|
|
164
|
+
Construct the Xbox API client from AuthenticationManager instance
|
|
165
|
+
"""
|
|
166
|
+
xbl_client = XboxLiveClient(auth_mgr)
|
|
167
|
+
|
|
168
|
+
"""
|
|
169
|
+
Some example API calls
|
|
170
|
+
"""
|
|
171
|
+
# Get friendslist
|
|
172
|
+
friendslist = await xbl_client.people.get_friends_own()
|
|
173
|
+
print(f"Your friends: {friendslist}\n")
|
|
174
|
+
|
|
175
|
+
# Get presence status (by list of XUID)
|
|
176
|
+
presence = await xbl_client.presence.get_presence_batch(
|
|
177
|
+
["2533274794093122", "2533274807551369"]
|
|
178
|
+
)
|
|
179
|
+
print(f"Statuses of some random players by XUID: {presence}\n")
|
|
180
|
+
|
|
181
|
+
# Get messages
|
|
182
|
+
messages = await xbl_client.message.get_inbox()
|
|
183
|
+
print(f"Your messages: {messages}\n")
|
|
184
|
+
|
|
185
|
+
# Get profile by GT
|
|
186
|
+
profile = await xbl_client.profile.get_profile_by_gamertag("SomeGamertag")
|
|
187
|
+
print(f"Profile under SomeGamertag gamer tag: {profile}\n")
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
asyncio.run(async_main())
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Contribute
|
|
194
|
+
|
|
195
|
+
- Report bugs/suggest features
|
|
196
|
+
- Add/update docs
|
|
197
|
+
- Add additional xbox live endpoints
|
|
198
|
+
|
|
199
|
+
## Credits
|
|
200
|
+
|
|
201
|
+
This package uses parts of [Cookiecutter](https://github.com/audreyr/cookiecutter)
|
|
202
|
+
and the [audreyr/cookiecutter-pypackage](https://github.com/audreyr/cookiecutter-pypackage) project template.
|
|
203
|
+
The authentication code is based on [joealcorn/xbox](https://github.com/joealcorn/xbox)
|
|
204
|
+
|
|
205
|
+
Informations on endpoints gathered from:
|
|
206
|
+
|
|
207
|
+
- [XboxLive REST Reference](https://docs.microsoft.com/en-us/windows/uwp/xbox-live/xbox-live-rest/atoc-xboxlivews-reference)
|
|
208
|
+
- [XboxLiveTraceAnalyzer APIMap](https://github.com/Microsoft/xbox-live-trace-analyzer/blob/master/Source/XboxLiveTraceAnalyzer.APIMap.csv)
|
|
209
|
+
- [Xbox Live Service API](https://github.com/Microsoft/xbox-live-api)
|
|
210
|
+
|
|
211
|
+
## Disclaimer
|
|
212
|
+
|
|
213
|
+
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,63 @@
|
|
|
1
|
+
webapi/__init__.py,sha256=hYekEIvBVPT4y6hddaSD3v12UnsmPtrqP8J4oPEGSmI,102
|
|
2
|
+
webapi/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
webapi/api/client.py,sha256=xVqzgN_sCH-9rluDBAjNJoBJTZVMyc2dQKB1wEfAM8Y,5796
|
|
4
|
+
webapi/api/language.py,sha256=ThovoFIkS7kv-S3dakcKU6xr5yLSb_kTMc4O4iCt744,3533
|
|
5
|
+
webapi/api/provider/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
webapi/api/provider/baseprovider.py,sha256=b5piCI4KenbJR2THin1zj3e-n72db7d10a4rXEdndXg,292
|
|
7
|
+
webapi/api/provider/ratelimitedprovider.py,sha256=ucJfjgwFlWR182MeTi4cCpjMzn1RTwz_P_epUkA_ygc,3060
|
|
8
|
+
webapi/api/provider/account/__init__.py,sha256=ZobvTwUnuD1kBj54Zx4rGrmzviJ6-e2n_OE2d3dNUH4,2249
|
|
9
|
+
webapi/api/provider/account/models.py,sha256=noWqiSMBLJukNN5g3AHjieuO9el8dDbuDDrXQpmpTQc,197
|
|
10
|
+
webapi/api/provider/achievements/__init__.py,sha256=mjz7l7taxAh3xtfloFNMCr3V4SJkdvukxvsjh2LVcVU,5243
|
|
11
|
+
webapi/api/provider/achievements/models.py,sha256=6jruvUTkgrhZD1T7wkNNOHzczb89CH9MrBxcr-R_g_Y,2684
|
|
12
|
+
webapi/api/provider/catalog/__init__.py,sha256=N_5JUOJDF-1dOMzPqoABiKOX0-vOtSJp1dFuV1RWbA4,2772
|
|
13
|
+
webapi/api/provider/catalog/const.py,sha256=2PPKo6y5shXeCH44EQM0v5C5Z9UWqN3hNLnhnZszzJo,463
|
|
14
|
+
webapi/api/provider/catalog/models.py,sha256=Z6NwiOXGtJPA3x47t6pj-N_tJ02iomtwyMRdGo0rTCQ,13029
|
|
15
|
+
webapi/api/provider/cqs/__init__.py,sha256=ctn8tikEDAABWlszlAaHyC8Tn552DNvpnp2_QNT4sIk,2668
|
|
16
|
+
webapi/api/provider/cqs/models.py,sha256=UbhyRu4W_vxpBAUnKIF30iNAenfpnEpxGe6kxFf3JiE,1161
|
|
17
|
+
webapi/api/provider/gameclips/__init__.py,sha256=wtUpFlwJaOcZiXGKPOuqZKKnNSQMz1BnAldc1WfqrN4,5532
|
|
18
|
+
webapi/api/provider/gameclips/models.py,sha256=neZ-XbEf5WmEVanbWmCn0ABFH1my1dGyaIA7S56cKR8,1220
|
|
19
|
+
webapi/api/provider/lists/__init__.py,sha256=YHbsMdjJOTtJaI4MpIuDe2ZVZHeTmXCL5xlFDxu3idM,2338
|
|
20
|
+
webapi/api/provider/lists/models.py,sha256=cXaL0_kd7FSnrLYSJZWDc6G615JXkOdi0A4vL7DTVLI,711
|
|
21
|
+
webapi/api/provider/mediahub/__init__.py,sha256=FVXFHRfy8BqZDfCf0Y8rsUGZ95LD4L4Vpbqw9gIMcg4,1829
|
|
22
|
+
webapi/api/provider/mediahub/models.py,sha256=dtyXa2WpYMXF58PZOIfmo059JEYp-uZMMrXz3uJE-rY,1911
|
|
23
|
+
webapi/api/provider/message/__init__.py,sha256=JYCnYQP0f78kE0WlxW7jOBEY2Z2-Adi4ZphW5xfzUa4,4165
|
|
24
|
+
webapi/api/provider/message/models.py,sha256=FwUwNjXUZ110v5a1Jtal08jtpQdbQ4juVf5tdh5q414,2070
|
|
25
|
+
webapi/api/provider/people/__init__.py,sha256=9C1oxwMPkk-WZJ3cJ-fBkUFcwp71pi0-xIw9vKKUjvQ,6499
|
|
26
|
+
webapi/api/provider/people/models.py,sha256=SCUvY0Fw4CC4Qu6KC-CxO8fGOILBp_kBxY5g5NAYVFM,6892
|
|
27
|
+
webapi/api/provider/presence/__init__.py,sha256=1dyJUEpyejNNi-oMLGvO0HLlmsbDTq8uiW7OrZgfAs4,3307
|
|
28
|
+
webapi/api/provider/presence/models.py,sha256=Ezw_kDHzDjAmOHPzIn_ZU1cXA6Ui3TXDdNw84lTbGcQ,1207
|
|
29
|
+
webapi/api/provider/profile/__init__.py,sha256=VWTUN27cel4RgGQ41PlRSo44GpLcjJpBAYwIGZsf_Zs,4958
|
|
30
|
+
webapi/api/provider/profile/models.py,sha256=wkX-A6dQeEiKO1v6MexXJcdvK4f_v3kG8TlwM5TxXoQ,1247
|
|
31
|
+
webapi/api/provider/screenshots/__init__.py,sha256=r3GBgWG005gOFdctIRkgX7-BnNISCoKAfm00N3IGL5s,5722
|
|
32
|
+
webapi/api/provider/screenshots/models.py,sha256=HWK6uYLeiL6u0-wVXzQkQ3ZFxzGImE4HRTI0Gc6R3Ko,1196
|
|
33
|
+
webapi/api/provider/smartglass/__init__.py,sha256=IEbh7Jmg9Zn3_2u4BQrDuiSNE_Ph0xFH3EUq8Cz4_QA,11430
|
|
34
|
+
webapi/api/provider/smartglass/models.py,sha256=APVcyhIUdhUZGGf658vot1RfexU0y7_7mcMUFH9OFCA,4365
|
|
35
|
+
webapi/api/provider/titlehub/__init__.py,sha256=M81SIus7ISsYbtnrWnm4pSZbOKEaLVF08aQKOWhrrO0,4526
|
|
36
|
+
webapi/api/provider/titlehub/models.py,sha256=m2k7rtqfdjfASvWySeZcYIR2XF13zcGALjFVU7UjkHc,2622
|
|
37
|
+
webapi/api/provider/usersearch/__init__.py,sha256=o_tDaVteFceU_o9WrLbEyhUOJC9-Z65sYIconcMqVDA,914
|
|
38
|
+
webapi/api/provider/usersearch/models.py,sha256=tYf261ko3T4H_ILMXauJjPtA3-ivAErZbCavJ12QgLE,333
|
|
39
|
+
webapi/api/provider/userstats/__init__.py,sha256=mBi_1cIhfyBZBUeECHngt1-8wQCll7UXdKWe67f2Kzo,5373
|
|
40
|
+
webapi/api/provider/userstats/models.py,sha256=qbJ4p1NhYLBHz6PlYSOdq7jA2JLdEMqomp4tw2VZY_U,1064
|
|
41
|
+
webapi/authentication/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
42
|
+
webapi/authentication/manager.py,sha256=9rflcoxOT42GZy9Srx27gJVY8AdSccI8x1s0U6f6UbE,5744
|
|
43
|
+
webapi/authentication/models.py,sha256=L79hmSO9GJwcwLIZjS0c9KMnwLhzi9eEz1KX7RgchSk,3580
|
|
44
|
+
webapi/authentication/xal.py,sha256=v4s9ILpd8AK6pkGO0dsHVdPcQdw0FCAnYsqwgEK_inM,11550
|
|
45
|
+
webapi/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
46
|
+
webapi/common/exceptions.py,sha256=9Ft-bUUeA0k_YKfltz94shVH1A9pAZZfpQsbH0k3ocs,1473
|
|
47
|
+
webapi/common/filetimes.py,sha256=_Kjg8vEt3cBO_ChfHYXXL-hCP6bx10ooGHHzl0UjVo4,3610
|
|
48
|
+
webapi/common/models.py,sha256=zIDOE7FnBKUmjcZ3FH8LSf3_OFaaZx1yHg7xUSHI844,816
|
|
49
|
+
webapi/common/request_signer.py,sha256=4A3NI3as9nhiiP_ULvnpHpZbAMUcaPAlLTVPs8qwcrE,5494
|
|
50
|
+
webapi/common/signed_session.py,sha256=fgilCUEnQKK5RHs28JhSbbZGA43HnHol33zC7te6onA,1758
|
|
51
|
+
webapi/common/ratelimits/__init__.py,sha256=r6PpvKKmgcjRvtzIE0lozhdAduxJzIdlnGP_SpykhCU,10142
|
|
52
|
+
webapi/common/ratelimits/models.py,sha256=UmvQGtLd_J33Idx3OlR7QepvhhGSUnKVIg1CvswNCho,358
|
|
53
|
+
webapi/scripts/__init__.py,sha256=2z6UFqu9f7FYKZ20WB5cljDUwaY_w7kc6ajdfYtuNEc,450
|
|
54
|
+
webapi/scripts/authenticate.py,sha256=Iy88ZLNPixjjN7-apqk9fM0ecL1Vnr_qKmdoNCRBi-U,5003
|
|
55
|
+
webapi/scripts/change_gamertag.py,sha256=Grkkv7Kuy8Ffau6VetO-s1VP1F-r0egK9puwOMv3bgs,3309
|
|
56
|
+
webapi/scripts/friends.py,sha256=E9x-wXJcs8jK0H2YS_QoMdWP8zzJ-D10rzQfz0Ihdxs,2128
|
|
57
|
+
webapi/scripts/search.py,sha256=Bs5A3lBEmOQ77ya7A3z9rqV-WHDQS8933IDpAloqRU4,1061
|
|
58
|
+
webapi/scripts/xal.py,sha256=ZAX8QtitSjVU1gABb6E8g5xzOEUhK0zVYX1rKRTpKkM,2940
|
|
59
|
+
python_xbox-0.1.0rc0.dist-info/METADATA,sha256=IL3HizasigkP4-psk29VXKMDimuS3ZUjo-2K4gHd5FQ,7515
|
|
60
|
+
python_xbox-0.1.0rc0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
61
|
+
python_xbox-0.1.0rc0.dist-info/entry_points.txt,sha256=_g3gfLC1KrQQbwsYdW_sLJnUEH8gSwLh9OzGqWNuQLo,272
|
|
62
|
+
python_xbox-0.1.0rc0.dist-info/licenses/LICENSE,sha256=GZZiedLyfDqT3SWPU1LLYtMxEkij8MDzUgerPOS9Smo,1052
|
|
63
|
+
python_xbox-0.1.0rc0.dist-info/RECORD,,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
[console_scripts]
|
|
2
|
+
xbox-authenticate = xbox.webapi.scripts.authenticate:main
|
|
3
|
+
xbox-change-gt = xbox.webapi.scripts.change_gamertag:main
|
|
4
|
+
xbox-friends = xbox.webapi.scripts.friends:main
|
|
5
|
+
xbox-searchlive = xbox.webapi.scripts.search:main
|
|
6
|
+
xbox-xal = xbox.webapi.scripts.xal:main
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2020 OpenXbox
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
webapi/__init__.py
ADDED
webapi/api/__init__.py
ADDED
|
File without changes
|
webapi/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 xbox.webapi.api.language import DefaultXboxLiveLanguages, XboxLiveLanguage
|
|
15
|
+
from xbox.webapi.api.provider.account import AccountProvider
|
|
16
|
+
from xbox.webapi.api.provider.achievements import AchievementsProvider
|
|
17
|
+
from xbox.webapi.api.provider.catalog import CatalogProvider
|
|
18
|
+
from xbox.webapi.api.provider.cqs import CQSProvider
|
|
19
|
+
from xbox.webapi.api.provider.gameclips import GameclipProvider
|
|
20
|
+
from xbox.webapi.api.provider.lists import ListsProvider
|
|
21
|
+
from xbox.webapi.api.provider.mediahub import MediahubProvider
|
|
22
|
+
from xbox.webapi.api.provider.message import MessageProvider
|
|
23
|
+
from xbox.webapi.api.provider.people import PeopleProvider
|
|
24
|
+
from xbox.webapi.api.provider.presence import PresenceProvider
|
|
25
|
+
from xbox.webapi.api.provider.profile import ProfileProvider
|
|
26
|
+
from xbox.webapi.api.provider.screenshots import ScreenshotsProvider
|
|
27
|
+
from xbox.webapi.api.provider.smartglass import SmartglassProvider
|
|
28
|
+
from xbox.webapi.api.provider.titlehub import TitlehubProvider
|
|
29
|
+
from xbox.webapi.api.provider.usersearch import UserSearchProvider
|
|
30
|
+
from xbox.webapi.api.provider.userstats import UserStatsProvider
|
|
31
|
+
from xbox.webapi.authentication.manager import AuthenticationManager
|
|
32
|
+
from xbox.webapi.common.exceptions import RateLimitExceededException
|
|
33
|
+
from xbox.webapi.common.ratelimits import RateLimit
|
|
34
|
+
|
|
35
|
+
log = logging.getLogger("xbox.api")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class Session:
|
|
39
|
+
def __init__(self, auth_mgr: AuthenticationManager):
|
|
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
|
+
):
|
|
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
|
webapi/api/language.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Language definitions
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class XboxLiveLanguage:
|
|
7
|
+
def __init__(self, name, short_id, identifier, locale):
|
|
8
|
+
"""
|
|
9
|
+
Initialize a new instance of :class:`XboxLiveLanguage`
|
|
10
|
+
|
|
11
|
+
Args:
|
|
12
|
+
name (str): Full name describing the language / country
|
|
13
|
+
short_id (str): Short Id (e.g. "AT" for Austria)
|
|
14
|
+
identifier (str): Identifier (e.g. "de_AT" for Austria)
|
|
15
|
+
locale (str): Locale (e.g. "de-AT" for Austria)
|
|
16
|
+
"""
|
|
17
|
+
self.name = name
|
|
18
|
+
self.short_id = short_id
|
|
19
|
+
self.identifier = identifier
|
|
20
|
+
self.locale = locale
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class DefaultXboxLiveLanguages:
|
|
24
|
+
"""
|
|
25
|
+
Collection of locales compatible with XBL
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
Argentina = XboxLiveLanguage("Argentina", "AR", "es_AR", "es-AR")
|
|
29
|
+
Australia = XboxLiveLanguage("Australia", "AU", "en_AU", "en-AU")
|
|
30
|
+
Austria = XboxLiveLanguage("Austria", "AT", "de_AT", "de-AT")
|
|
31
|
+
Belgium = XboxLiveLanguage("Belgium", "BE", "fr_BE", "fr-BE")
|
|
32
|
+
Belgium_NL = XboxLiveLanguage("Belgium (NL)", "NL", "nl_BE", "nl-BE")
|
|
33
|
+
Brazil = XboxLiveLanguage("Brazil", "BR", "pt_BR", "pt-BR")
|
|
34
|
+
Canada = XboxLiveLanguage("Canada", "CA", "en_CA", "en-CA")
|
|
35
|
+
Canada_FR = XboxLiveLanguage("Canada (FR)", "CA", "fr_CA", "fr-CA")
|
|
36
|
+
Czech_Republic = XboxLiveLanguage("Czech Republic", "CZ", "en_CZ", "en-CZ")
|
|
37
|
+
Denmark = XboxLiveLanguage("Denmark", "DK", "da_DK", "da-DK")
|
|
38
|
+
Finland = XboxLiveLanguage("Finland", "FI", "fi_FI", "fi-FI")
|
|
39
|
+
France = XboxLiveLanguage("France", "FR", "fr_FR", "fr-FR")
|
|
40
|
+
Germany = XboxLiveLanguage("Germany", "DE", "de_DE", "de-DE")
|
|
41
|
+
Greece = XboxLiveLanguage("Greece", "GR", "en_GR", "en-GR")
|
|
42
|
+
Hong_Kong = XboxLiveLanguage("Hong Kong", "HK", "en_HK", "en-HK")
|
|
43
|
+
Hungary = XboxLiveLanguage("Hungary", "HU", "en_HU", "en-HU")
|
|
44
|
+
India = XboxLiveLanguage("India", "IN", "en_IN", "en-IN")
|
|
45
|
+
Great_Britain = XboxLiveLanguage("Great Britain", "GB", "en_GB", "en-GB")
|
|
46
|
+
Israel = XboxLiveLanguage("Israel", "IL", "en_IL", "en-IL")
|
|
47
|
+
Italy = XboxLiveLanguage("Italy", "IT", "it_IT", "it-IT")
|
|
48
|
+
Japan = XboxLiveLanguage("Japan", "JP", "ja_JP", "ja-JP")
|
|
49
|
+
Mexico = XboxLiveLanguage("Mexico", "MX", "es_MX", "es-MX")
|
|
50
|
+
Chile = XboxLiveLanguage("Chile", "CL", "es_CL", "es-CL")
|
|
51
|
+
Colombia = XboxLiveLanguage("Colombia", "CO", "es_CO", "es-CO")
|
|
52
|
+
Netherlands = XboxLiveLanguage("Netherlands", "NL", "nl_NL", "nl-NL")
|
|
53
|
+
New_Zealand = XboxLiveLanguage("New Zealand", "NZ", "en_NZ", "en-NZ")
|
|
54
|
+
Norway = XboxLiveLanguage("Norway", "NO", "nb_NO", "nb-NO")
|
|
55
|
+
Poland = XboxLiveLanguage("Poland", "PL", "pl_PL", "pl-PL")
|
|
56
|
+
Portugal = XboxLiveLanguage("Portugal", "PT", "pt_PT", "pt-PT")
|
|
57
|
+
Russia = XboxLiveLanguage("Russia", "RU", "ru_RU", "ru-RU")
|
|
58
|
+
Saudi_Arabia = XboxLiveLanguage("Saudi Arabia", "SA", "en_SA", "en-SA")
|
|
59
|
+
Singapore = XboxLiveLanguage("Singapore", "SG", "en_SG", "en-SG")
|
|
60
|
+
Slovakia = XboxLiveLanguage("Slovakia", "SK", "en_SK", "en-SK")
|
|
61
|
+
South_Africa = XboxLiveLanguage("South Afrida", "ZA", "en_ZA", "en-ZA")
|
|
62
|
+
Korea = XboxLiveLanguage("Korea", "KR", "ko_KR", "ko-KR")
|
|
63
|
+
Spain = XboxLiveLanguage("Spain", "ES", "es_ES", "es-ES")
|
|
64
|
+
Switzerland = XboxLiveLanguage("Switzerland", "CH", "de_CH", "de-CH")
|
|
65
|
+
Switzerland_FR = XboxLiveLanguage("Switzerland (FR)", "CH", "fr_CH", "fr-CH")
|
|
66
|
+
United_Arab_Emirates = XboxLiveLanguage(
|
|
67
|
+
"United Arab Emirates", "AE", "en_AE", "en-AE"
|
|
68
|
+
)
|
|
69
|
+
United_States = XboxLiveLanguage("United States", "US", "en_US", "en-US")
|
|
70
|
+
Ireland = XboxLiveLanguage("Ireland", "IE", "en_IE", "en-IE")
|
|
File without changes
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from xbox.webapi.api.provider.account.models import (
|
|
2
|
+
ChangeGamertagResult,
|
|
3
|
+
ClaimGamertagResult,
|
|
4
|
+
)
|
|
5
|
+
from xbox.webapi.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(self, xuid, gamertag, **kwargs) -> ClaimGamertagResult:
|
|
16
|
+
"""
|
|
17
|
+
Claim gamertag
|
|
18
|
+
|
|
19
|
+
XLE error codes:
|
|
20
|
+
400 - Bad API request
|
|
21
|
+
401 - Unauthorized
|
|
22
|
+
409 - Gamertag unavailable
|
|
23
|
+
429 - Too many requests
|
|
24
|
+
200 - Gamertag available
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
xuid (int): Your xuid as integer
|
|
28
|
+
gamertag (str): Desired gamertag
|
|
29
|
+
|
|
30
|
+
Returns: ClaimGamertagResult
|
|
31
|
+
"""
|
|
32
|
+
url = self.BASE_URL_USER_MGT + "/gamertags/reserve"
|
|
33
|
+
post_data = {"Gamertag": gamertag, "ReservationId": str(xuid)}
|
|
34
|
+
resp = await self.client.session.post(
|
|
35
|
+
url, json=post_data, headers=self.HEADERS_USER_MGT, **kwargs
|
|
36
|
+
)
|
|
37
|
+
try:
|
|
38
|
+
return ClaimGamertagResult(resp.status_code)
|
|
39
|
+
except ValueError:
|
|
40
|
+
resp.raise_for_status()
|
|
41
|
+
|
|
42
|
+
async def change_gamertag(
|
|
43
|
+
self, xuid, gamertag, preview=False, **kwargs
|
|
44
|
+
) -> ChangeGamertagResult:
|
|
45
|
+
"""
|
|
46
|
+
Change your gamertag.
|
|
47
|
+
|
|
48
|
+
XLE error codes:
|
|
49
|
+
200 - success
|
|
50
|
+
1020 - No free gamertag changes available
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
xuid (int): Your Xuid as integer
|
|
54
|
+
gamertag (str): Desired gamertag name
|
|
55
|
+
preview (bool): Preview the change
|
|
56
|
+
|
|
57
|
+
Returns: ChangeGamertagResult
|
|
58
|
+
"""
|
|
59
|
+
url = self.BASE_URL_ACCOUNT + "/users/current/profile/gamertag"
|
|
60
|
+
post_data = {
|
|
61
|
+
"gamertag": gamertag,
|
|
62
|
+
"preview": preview,
|
|
63
|
+
"reservationId": int(xuid),
|
|
64
|
+
}
|
|
65
|
+
resp = await self.client.session.post(
|
|
66
|
+
url, json=post_data, headers=self.HEADERS_ACCOUNT, **kwargs
|
|
67
|
+
)
|
|
68
|
+
try:
|
|
69
|
+
return ChangeGamertagResult(resp.status_code)
|
|
70
|
+
except ValueError:
|
|
71
|
+
resp.raise_for_status()
|