Darshan Hiranandani : Is There a Login API Endpoint for DHIS2 Authentication?

Hi everyone,

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?

Looking forward to your insights!

Thanks!
Regards
Darshan Hiranandani

Hi @darshanhiranandani23

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.

Read more here Develop - Using the Api - #webapi_oauth2.

You can also check out another simpler option using Okta (or similar OIDC options): Configure OpenID Connect with Okta - DHIS2 Documentation

Would you like to share the use case for having to develop this custom integration?

Thank you!