Skip to content

Support login using email and password #28

@Fkawala

Description

@Fkawala

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 token

I might do a PR if you think this is a desirable feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions