End Points Guide
End Points 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
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#"
}