Upload files to "/"

This commit is contained in:
b016488d-939a-4910-a596-93b77fc9ab9c
2026-07-24 15:26:33 +00:00
parent 99bb20a1e9
commit d061cf5c8d
4 changed files with 195 additions and 15 deletions

View File

@@ -8,6 +8,7 @@ RecNetDomain = "rec.net"
auth = None
refreshToken = None
clientSecret = "54oc5C4BH7jpqp42KhChkNZOLP0U3yTx"
clientId = "recroom.studio"#recroom.studio
c = httpx.Client(http1=False, http2=True)
@@ -87,7 +88,7 @@ def sendRequest(method: HTTPMethod, service: Service, path: str, useAuth=True, j
scheme = "https"
url = f"{scheme}://{service.value}.{RecNetDomain}/{path}"
headers = {
"User-Agent": "BestHTTP"
"User-Agent": "RRStudio"
}
if auth and useAuth:
headers.update({
@@ -103,23 +104,13 @@ def sendRequest(method: HTTPMethod, service: Service, path: str, useAuth=True, j
raise RecNetError(f"Failed to refresh token: {re.error}")
auth = re.accessToken
refreshToken = re.refreshToken
sendRequest(method, service, path, json=json, files=files, data=data, https=https)
return sendRequest(method, service, path, json=json, files=files, data=data, https=https)
else:
raise RecNetError("Unauthorized: No access token provided.")
return req
def genAuthCode():
"""
Generates a device authorization code by sending a POST request to the authentication api.
Returns:
dto.DeviceAuthorization: An object containing the device authorization response if successful.
None: If the request fails or no response is received.
Side Effects:
Prints an error message to the console if the device authorization response fails.
"""
payload = {"client_id": "recroom.studio", "client_secret": clientSecret}
payload = {"client_id": clientId, "client_secret": clientSecret}
req = sendRequest(HTTPMethod.POST, Service.Auth, "connect/deviceauthorization", data=payload)
if req is not None:
return dto.DeviceAuthorization(req.json())
@@ -128,7 +119,7 @@ def genAuthCode():
return None
def loginWithDeviceCode(DeviceCode: str):
payload = {"client_id": "recroom.studio", "client_secret": clientSecret, "grant_type": "urn:ietf:params:oauth:grant-type:device_code", "device_code": DeviceCode}
payload = {"client_id": clientId, "client_secret": clientSecret, "grant_type": "urn:ietf:params:oauth:grant-type:device_code", "device_code": DeviceCode}
req = sendRequest(HTTPMethod.POST, Service.Auth, "connect/token", data=payload)
if req is not None:
return dto.Login(req.json())
@@ -137,7 +128,7 @@ def loginWithDeviceCode(DeviceCode: str):
return None
def loginWithRefreshToken(refreshToken: str):
payload = {"client_id": "recroom.studio", "client_secret": clientSecret, "grant_type": "refresh_token", "refresh_token": refreshToken}
payload = {"client_id": clientId, "client_secret": clientSecret, "grant_type": "refresh_token", "refresh_token": refreshToken}
req = sendRequest(HTTPMethod.POST, Service.Auth, "connect/token", data=payload)
print(refreshToken)
if req is not None: