0% found this document useful (0 votes)
57 views3 pages

End Points Guide

The document outlines the steps to register a new user, log in an existing user, and reset the password of an existing user for a smart IoT application API. It provides the HTTP methods, endpoints, request bodies and expected responses for each step.

Uploaded by

nadeeshan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views3 pages

End Points Guide

The document outlines the steps to register a new user, log in an existing user, and reset the password of an existing user for a smart IoT application API. It provides the HTTP methods, endpoints, request bodies and expected responses for each step.

Uploaded by

nadeeshan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

GUIDE

Register

Step 1
Create user (POST)
http://smart-iot-app.herokuapp.com/auth/users/
{
"name": "anton",
"email": "[email protected]",
"password": "anton#123#",
"re_password": "anton#123#"
}
Response:
Success - HTTP_201_CREATED
{
     "name": " anton",
     "email": " [email protected]",
     "id": 1
}
On failiure - HTTP_400_BAD_REQUEST
{errors}

 If the respond is 201 then move to the step 2. So in the front end, use if/else. If the respond is
success, then automatically run the step 2 end point. Else display the error

Step 2
Send OTP (PUT)
http://smart-iot-app.herokuapp.com/auth/send_otp
{
    "email": "[email protected]"
}
respond: onsuccess - 204_NO_CONTENT
on failiure - 400_BAD_REQUEST

 Then user will receive a email with a 6 digit code


Step 3
Activate User (PUT)
http://smart-iot-app.herokuapp.com/auth/user_verification
{
    "email": "[email protected]",
    "otp": "912167"
}
response: onsuccess - {'detail': 'Account Activated!'} -200_OK
onFailiure - {'error': 'Failed to activate'} - 401_UNAUTHORIZED

login
User Login (POST)
http://smart-iot-app.herokuapp.com/auth/jwt/create/
{
    "email":"[email protected]",
    "password":"anton#123#"
}

Response:
Success - HTTP_200_OK
{
    "refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVz
aCIsImV4cCI6MTYwNjc1MjIzNiwianRpIjoiY2YwNjg3NTM1NWE0NDI3Zjk4OWIzOWN
jYTk3MjNlNjEiLCJ1c2VyX2lkIjoxfQ.A5MY11sijX5WWWXHE7L_RMmd_KXP_HwKPh
QRyYx_PLg",
   
    "access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNz
IiwiZXhwIjoxNjA2NjY2MTM2LCJqdGkiOiJhNWViYzRiNzZiMmE0YzlhYjEyZGYzMjg4
YTIwYWYzNyIsInVzZXJfaWQiOjF9.BWwA1gPMD9fJO2wtGCTyz7QNPsFvpUgb4Op-
Gh7z0HA"
    }

On failiure - HTTP_401_UNAUTHORIZED
{errors}
Reset password
Step 1
Request for reset password (PUT)
http://smart-iot-app.herokuapp.com/auth/send_otp
{
    "email": "[email protected]"
}
 Then the user will receive a email with a 6 digit code

Step 2
OTP Verification (POST)
http://smart-iot-app.herokuapp.com/auth/user_verification

{
    "email": "[email protected]",
    "otp": "666129"
}
response: onsuccess - {'detail': 'Email verified!'} -200_OK
onFailiure - {'error': 'Failed to verify'} - 401_UNAUTHORIZED

Step 3
Set New password (PATCH)
http://smart-iot-app.herokuapp.com/auth/set_new_password
{
    "email": "[email protected]",
    "password1": "abc@123#",
    "password2": "abc@123#"
}

response: onsuccess - context = {


'success': True,
'msg': 'Password Reset Success!'
} -200_OK
onFailiure - context = {
'success': False,
'msg': 'Verification failed!'
} - 401_UNAUTHORIZED

You might also like