HumanSignal / label-studio-sdk

Label Studio SDK
https://api.labelstud.io
Apache License 2.0
99 stars 61 forks source link

How to create a new user and login #124

Open jet-c-21 opened 1 year ago

jet-c-21 commented 1 year ago
user_dict = {
                'username': 'user1',
                'email': 'user1@ichase.com',
                'first_name': 'xxx',
                'last_name': 'xxx',
                'phone': '',
            }

# new_user.set_role(UserRole.ANNOTATOR)
created_user = ls.create_user(user_dict)
print(created_user)

how can I login with my created user, I don't see any doc for assigning password for the created user

fdejax90 commented 7 months ago

I tried to create a first user and log in, but complaining about missing attribute cookies even though it is set by default to None here

from label_studio_sdk.client import ClientCredentials

credentials = ClientCredentials(email='foo@foo.com', password='foo')
ls = Client(url=LABEL_STUDIO_URL, credentials=credentials)

>>>  
  File "/Users/.local/share/virtualenvs/ND9qtml7/lib/python3.12/site-packages/label_studio_sdk/client.py", line 91, in __init__
    else self.get_api_key(credentials)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.local/share/virtualenvs/ND9qtml7/lib/python3.12/site-packages/label_studio_sdk/client.py", line 129, in get_api_key
    cookies=self.cookies,
            ^^^^^^^^^^^^
AttributeError: 'Client' object has no attribute 'cookies'
makseq commented 5 months ago

@fdejax90 please try it now with the latest LS SDK (0.0.34) or install it from the github repo.

makseq commented 5 months ago

BTW, In Label Studio Enterprise it's possible to create a user with password using the same API call.