-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhelpers.py
More file actions
109 lines (82 loc) · 3.56 KB
/
helpers.py
File metadata and controls
109 lines (82 loc) · 3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import os
import sys
import json
import asyncio
import requests
# def GenerateBearerToken(authorization_code: str) -> object:
# reqUrl = "https://account-public-service-prod.ol.epicgames.com/account/api/oauth/token"
# headersList = {
# "Content-Type": "application/x-www-form-urlencoded",
# "Authorization": "basic ZWM2ODRiOGM2ODdmNDc5ZmFkZWEzY2IyYWQ4M2Y1YzY6ZTFmMzFjMjExZjI4NDEzMTg2MjYyZDM3YTEzZmM4NGQ="
# }
# payload = f"grant_type=authorization_code&code={authorization_code}"
# response = requests.post(reqUrl, data=payload, headers=headersList)
# return response.json()
def QueryProfile(accountId: str, profileId: str, bearer: str) -> object:
reqUrl = f"https://fortnite-public-service-prod11.ol.epicgames.com/fortnite/api/game/v2/profile/{accountId}/client/QueryProfile?profileId={profileId}"
headersList = {
"Authorization": f"bearer {bearer}",
"Content-Type": "application/json"
}
payload = json.dumps({})
response = requests.post(reqUrl, data=payload, headers=headersList)
return response.json()
def CheckBundle(bundleId, data, profileItems, fnggItems) -> int:
countOfShould = len(data['items'])
countOfActual = 0
for i in data['items']:
if type(i) is not bool and i.lower() in profileItems:
countOfActual += 1
if countOfShould == countOfActual:
return fnggItems[bundleId.lower()]
else:
return None
def getJsonPath(filename):
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, filename)
return os.path.join(os.path.dirname(__file__), filename)
# DEVICE CODE AUTH (https://github.com/xMistt/DeviceAuthGenerator)
SWITCH_TOKEN = "OThmN2U0MmMyZTNhNGY4NmE3NGViNDNmYmI0MWVkMzk6MGEyNDQ5YTItMDAxYS00NTFlLWFmZWMtM2U4MTI5MDFjNGQ3"
async def getAccessToken(http_session) -> str:
async with http_session.request(
method="POST",
url="https://account-public-service-prod.ol.epicgames.com/account/api/oauth/token",
headers={
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": f"basic {SWITCH_TOKEN}",
},
data={
"grant_type": "client_credentials",
},
) as request:
data = await request.json()
return data["access_token"]
async def createDeviceCode(http_session, access_token) -> tuple:
async with http_session.request(
method="POST",
url="https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/deviceAuthorization",
headers={
"Authorization": f"bearer {access_token}",
"Content-Type": "application/x-www-form-urlencoded",
},
) as request:
data = await request.json()
return data["verification_uri_complete"], data["device_code"]
async def waitForDeviceCodeComplete(http_session, code) -> dict:
while True:
async with http_session.request(
method="POST",
url="https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/token",
headers={
"Authorization": f"basic {SWITCH_TOKEN}",
"Content-Type": "application/x-www-form-urlencoded",
},
data={"grant_type": "device_code", "device_code": code},
) as request:
if request.status == 200:
auth_data = await request.json()
break
else:
pass
await asyncio.sleep(3)
return auth_data