label-studio-sdk icon indicating copy to clipboard operation
label-studio-sdk copied to clipboard

How to create a new user and login

Open jet-c-21 opened this issue 2 years ago • 3 comments

user_dict = {
                'username': 'user1',
                'email': '[email protected]',
                '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

jet-c-21 avatar Apr 18 '23 08:04 jet-c-21

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='[email protected]', 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'

fdejax90 avatar Apr 15 '24 18:04 fdejax90

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

makseq avatar May 22 '24 13:05 makseq

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

makseq avatar May 23 '24 13:05 makseq