Created
October 7, 2024 17:41
-
-
Save itisFarzin/78911e0934827d54fd4842ef26718b97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
headers = { | |
'accept': 'application/json', | |
'accept-language': 'en,fa-IR;q=0.9,fa;q=0.8', | |
'content-type': 'application/json', | |
'origin': 'https://foss.crave.io', | |
} | |
json_data = { | |
'type': 'email', | |
'email': 'email', | |
'password': 'password', | |
} | |
response = requests.post('https://foss.crave.io/api/auth/v1/signIn', headers=headers, json=json_data).json() | |
teamId = response["data"]["defaultTeam"] | |
token = response["data"]["token"] | |
headers["authorization"] = token | |
json_data = { | |
'action': 'list', | |
'page': 1, | |
'limit': 1, | |
'sort': { | |
'jobId': 'desc', | |
}, | |
'filter': { | |
'teamId': teamId, | |
'type': 'interactive', | |
'status': 'running', | |
'serviceReq': { | |
'operator': 'contains', | |
'value': { | |
'devspaceNode': 'true', | |
}, | |
}, | |
'user.id': response["data"]["userId"], | |
}, | |
} | |
response = requests.post('https://foss.crave.io/api/job/v1/get', headers=headers, json=json_data).json() | |
if len(response["data"]["content"]) == 0: | |
response = requests.post('https://foss.crave.io/api/job/v1/createSession', headers=headers, json={'teamId': teamId}).json() | |
if not response["success"]: | |
print("Failed to create session") | |
else: | |
print("Session created") | |
else: | |
print("You already have a session") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment