-
Notifications
You must be signed in to change notification settings - Fork 107
Closed
Description
It could be implemented in the Client class using something like :
def get_label_studio_token(host: str, email: str, password: str):
url = f'http://{host}/user/login'
client = requests.session()
# Retrieve and set the CSRF token first
client.get(url)
# Django 1.6 and up use csrftoken wheras previous version use csrf
csrf_token = client.cookies.get('csrftoken', None)
login_data = dict(email=email, password=password, csrfmiddlewaretoken=csrf_token)
client.post(url, data=login_data, headers=dict(Referer=url)).raise_for_status()
token = client.get(f"http://{host}/api/current-user/token").json().get("token")
return tokenI might do a PR if you think this is a desirable feature.
Metadata
Metadata
Assignees
Labels
No labels