Skip to content

Instantly share code, notes, and snippets.

@itisFarzin
Created October 7, 2024 17:41
Show Gist options
  • Save itisFarzin/78911e0934827d54fd4842ef26718b97 to your computer and use it in GitHub Desktop.
Save itisFarzin/78911e0934827d54fd4842ef26718b97 to your computer and use it in GitHub Desktop.
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