I’m Darshan Hiranandani, working on integrating user authentication with a DHIS2 instance and wanted to know if there is an API endpoint that allows me to log in by posting a username and password.
Specifically, I’m looking for a solution where I can send a POST request with the user credentials (e.g., username and password) and have the system authenticate the user.
For example, I am thinking of something like this in JavaScript with Axios:
const response = await axios.post(‘https://your-dhis2-instance/api/login’, { username, password });
Is there a login API available for DHIS2, or is there another recommended approach for this?
Thank you for sharing about your project. Have you considered the potential security risks when sending the user credentials in a POST request? Additionally, is this script running on a the server-side?
DHIS2 supports the OAuth2 authentication protocol which is the more secure method.
OAuth2 is an open standard for authorization which allows third-party clients to connect on behalf of a DHIS2 user and get a reusable bearer token for subsequent requests to the Web API.