Login User

Estimated reading: 2 minutes

Login User

Use this API to login a user from anywhere, including web browsers, native applications on Android and iOS.

API URL:

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

Method: POST

Form Data Parameters:
				
					{
  "username": "Your_Username",
  "password": "Your_Password",
  "parent_id": 50511
}

				
			
URL Parameters Required
format = json (In future, Maybe change to default)
Yes
parent_id
No
Success Response
				
					{
  "code": 200,
  "message": "success",
  "data": {
    "token": "b9e223b8c1d2917a28f6cf774c3ef720356cef7a6f37189db66ef41e3d468587e11b157e872c99d82935e5292f2f31944e48017a930e9a128c494e63"
  }
}

				
			
Error Response
				
					{
  "code": 401,
  "message": "fail",
  "data": {
    "error": "Invalid email or password"
  }
}

				
			

OR

				
					{
  "code": 401,
  "message": "fail",
  "data": {
    "[email]": [
      "This field is missing."
    ]
  }
}

				
			

OR

				
					{
  "code": 401,
  "message": "fail",
  "data": {
    "[password]": [
      "This field is missing."
    ],
    "[email]": [
      "This field is missing."
    ]
  }
}

				
			

OR

				
					{
  "code": 401,
  "message": "fail",
  "data": {
    "[password]": [
      "This field is missing."
    ]
  }
}

				
			

OR

				
					{
  "code": 401,
  "message": "fail",
  "data": {
    "[password]": [
      "This value should not be blank."
    ]
  }
}


				
			

Code example

Here’s an example code snippet in Python using the requests library to make the API call to the “Login User” endpoint:

Python Example:

Here’s a corresponding example using cURL command in the command line:

cURL Example:

				
					import requests

url = 'http://<server-ip-address>/custom_api/login'
data = {
    'username': 'Your_Username',
    'password': 'Your_Password',
    'parent_id': 50511
}

response = requests.post(url, json=data)
if response.status_code == 200:
    json_response = response.json()
    token = json_response['data']['token']
    print('Login successful. Token:', token)
else:
    print('Login failed:', response.json()['data']['error'])

				
			
				
					curl -X POST -H "Content-Type: application/json" -d '{
    "username": "Your_Username",
    "password": "Your_Password",
    "parent_id": 50511
}' http://<server-ip-address>/custom_api/login

				
			
Share this Doc

Login User

Or copy link

CONTENTS