User Management: Login User

Estimated reading: 2 minutes

Description :

Use this API to Login user from anywhere (Web Browser, Native application in Android, iOS).

URL :

				
					http://<server-ip-address>/custom_api/login

				
			
Method : POST
URL Parameters Required
json or form-data
Yes
Optional
Parent_id

Form Data Parameters:

KeyValue
Email[string]
password[alphanumeric]
parent_id[integer]

Example :

				
					{
	"email": "abc111@gmail.com",
	"password": "comples@&*@#",
	"parent_id": 50511
}

				
			

Success Response :

code : 200

Content :

				
					{
    "code": 200,
    "message": "success",
    "data": {
        "token": "b9e223b8c1d2917a28f6cf774c3ef720356cef7a6f37189db66ef41e3d468587e11b157e872c99d82935e5292f2f31944e48017a930e9a128c494e63"
    }
}

				
			
PHP Code :
				
					<?php

$url = "http://<server-ip-address>/custom_api/login";
$headers = array(
    'Content-type: application/json'
);
$data = array(
    "email" => "abc111@gmail.com",
    "password" => "comples@&*@#",
    "parent_id" => 50511
);

$options = array(
    'http' => array(
        'header' => $headers,
        'method' => 'POST',
        'content' => json_encode($data)
    )
);

$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);

if ($response === FALSE) {
    // Handle error
}

var_dump($response);

?>

				
			
Javascript Code :
				
					const url = "http://<server-ip-address>/custom_api/login";
const data = {
  email: "abc111@gmail.com",
  password: "comples@&*@#",
  parent_id: 50511
};

fetch(url, {
  method: "POST",
  headers: {
    "Content-Type": "application/json"
  },
  body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));

				
			

cURL Code :

				
					curl -X POST "http://<server-ip-address>/custom_api/login" \
     -H "Content-Type: application/json" \
     -d '{
          "email":"abc111@gmail.com",
          "password":"comples@&*@#",
          "parent_id":50511
         }'

				
			

Make sure to replace <server-ip-address> with the actual server IP address or hostname where the API is hosted.

Please note that the password provided in the examples might need to be properly encoded or handled depending on the exact requirements of the API. Always ensure that you are following the proper security practices for handling user authentication.

Error Response :

Invalid API Token

Code :

  • Various 401 BAD REQUEST responses detailed in the request

Note :

Refer to the code examples in the previous response for how to make a request to this endpoint using PHP, JavaScript, and cURL. Make sure to replace <server-ip-address> with the actual server IP address or hostname where the API is hosted.

Share this Doc

User Management: Login User

Or copy link

CONTENTS