Setting user password after creating user using REST API

Hi everyone,

I am using JupyterHub 4 with the PAM authenticator and I would like to create users using the REST API, i.e. set a username and a password.

The following Python code works so far:

import requests

user_data = {'usernames': ['newusername'],
             'admin': False,

response =
    headers={'Authorization': f'token 0bxxxxxxxxxxxxxxxxxxxxxxxdg'},

if response.status_code == 201:
    print('It worked.')
    print('It failed.')

However, the user is created without setting a password. I checked the Jupyter REST API Documentation but couldn’t find anything related to the password.

The same applies when not using the API: If I, as an admin user, create a new user in the JupyterLab web interface, I don’t see any option to set the password.

How can I set the password?

Thanks a lot!

You cannot create user passwords via JupyterHub for PAM authenticator. You will have to do it using standard linux way passwd $USER. Check this post from another thread on a similar question.