User authentication API can be used to easily authenticate users for mobile applications. The application returns JWT token after login/signup which is used later for the as a header for remaining APIs.
API's are hosted on EC2.
User-Authentication-API can be used to login, signup user and get user specific information.
In the examples on this page, you would replace [TOKEN] with the token returned by this API after user SignUp/Login.
POST [server URL]/api/user/login
-
Request Payload -
{ "email" : "[email protected]", "password" : "123456" }
-
Response Payload-
"status": 200, "id": "5d8b97164dfcab1a47b215ed", "token":"[TOKEN]", "name": "Chandler Bing", "email": "[email protected]" }
-
Status codes -
- 200 - success
- 400 - Invalid email/password
POST [server URL]/api/user/signUp
-
Request payload -
{ "firstName":"Chandler", "lastName" : "Bing", "gender" : "Male", "contactNo" : "7047059630", "age" : "25", "email" : "[email protected]", "password" : "123456" }
-
Response Payload -
{ "status": 200, "token": [TOKEN], "userId": "5d8b97164dfcab1a47b215ed", "name": "Chandler Bing", "email": "[email protected]", "contactNo": "7047059630" }
-
Status codes -
- 200 - success
- 400 - Bad request(Some input parameter is not provided)
GET [server URL]/api/user/details
- Request Payload(Header) -
“token” :[TOKEN]
- Response Payload-
{
"status": 200,
"userId": "5d8b97164dfcab1a47b215ed",
"firstName": "Chandler",
"lastName": "Bing",
"email": "[email protected]",
"gender": "Male",
"contactNo": "7047059630",
"age": "25",
"createdAt": "2019-09-25T16:34:30.203Z"
}
- Status codes -
- 200 - success
- 400 - Access denied. Token not provided
- 401 - Invalid token
PUT [server URL]/api/user/update
- Request Payload -
{
"firstName":"Joey",
"lastName" : "Tribbiani",
"gender" : "Male",
"contactNo" : "7048763263",
"age" : "20"
}
- Header -
“token” : [TOKEN]
- Response Payload -
{
"status": 200,
"message": "User details updated successfully"
}
- Status codes -
- 200 - success
- 400 - User not found in the database
- 401 - Invalid token
DELETE [server URL]/api/user/delete
-
Request Payload -
- Header - “token” : [TOKEN]
-
Response Payload -
{ "status": 200, "message": "User details deleted successfully" }
-
Status codes -
- 200 - success
- 400 - Access Denied. Token Not provided / User not found in the database
- 401 - Invalid token