Open KiKariJeZZa opened 1 year ago
Hi! I agree, it would be a nice feature, but it's not implemented yet. As a workaround, you can do the following:
Open any CVAT page in browser, open the developer tools (F12 in Chrome)
Open Network tab, select any request, open the Headers tab
Find header values for the Authorization and Cookies headers:
Create a script like this (this one exports the tasks specified):
import os
import sys
from cvat_sdk import make_client
from cvat_sdk.core.helpers import DeferredTqdmProgressReporter
API_KEY = os.getenv("CVAT_API_KEY", "<authorization token>")
API_SESSIONID = os.getenv("CVAT_API_SESSIONID", "<session id>")
API_CSRFTOKEN = os.getenv("CVAT_API_CSRFTOKEN", "<csrf token>")
def main(argv=None):
assert API_KEY and API_SESSIONID and API_CSRFTOKEN
with make_client("https://app.cvat.ai", port=443) as client:
client.api_client.set_default_header("Authorization", f"Token {API_KEY}")
client.api_client.cookies["sessionid"] = API_SESSIONID
client.api_client.cookies["csrftoken"] = API_CSRFTOKEN
# client.organization_slug = ""
client.config.status_check_period = 2
for task_id in [1, 2, 3, 4, 5]:
task = client.tasks.retrieve(task_id)
task.export_dataset("CVAT for images", filename=f"task-{task_id}-cvat_for_images.zip",
pbar=DeferredTqdmProgressReporter(), include_images=True
)
main(sys.argv)
python export_tasks.py
or CVAT_API_KEY=... CVAT_API_SESSIONID=... CVAT_API_CSRFTOKEN=... python export_tasks.py
Thank you! Seems to work great. Please update me if ever that feature gets added :)
I dont see either Authorization or Cookie in my Request Headers:
@Pari-singh, you need to login in the browser first.
+1 much needed feature
My actions before raising this issue
Expected Behaviour
I should be able to authenticate using SSO and be able to use the CVAT Python SDK to write Python scripts that utilises the API to download/export dataset and whatever else I may need to do.
Current Behaviour
I am unable to find anywhere in documentation on how to do this as authentication usually requires a password:
configuration = Configuration( username='YOUR_USERNAME', password='YOUR_PASSWORD', )
whereas I only use SSO to use CVAT.
Context
By using Python Scripts to export and download datasets allows modularity for my labelling workflow architecture.
Your Environment