How to import user details including passwords using the user/userCredentials resource of WebAPI

I am trying to import users from one dhis2 instance to another using the web API. However using /api/26/users or /api/26/userCredentials endpoint I am not able to get the passwords in my resulting payload. All other user details can be exported.

3 Likes

Hi Philip,

You can think of exploring the use of a SQL query to update the User details in the database direclty based on the UID’s as described here by Emma: Migrate User Credentials to new Production Server.

Let us know if this works best for you.

Regards,
James.

1 Like

Thank you @jomutsani for the quick response. I will try this option out. Does this then mean that the WebAPI does not support export of the passwords via these endpoints? The documentation indicates so.

3 Likes

Hi @paleu256

DHIS2 does not expose passwords out of the API for security reasons and also from the way the passwords are hashed (bcrypt). You can however copy the usernames/passwords over to another instance with SQL.

Best,
James.

1 Like

Thanks James. The SQL way did it for me. We also need to update the documentation to communicate this critical feature.

Philip

2 Likes

Nice to know you are sorted @paleu256

I will definitely check the documentation then share this with the team.

Best,
James.

1 Like

This is really great information, thank you all for following up and recommending changes to the documentation.

2 Likes