-
Notifications
You must be signed in to change notification settings - Fork 5
Endpoints
URL : /api/registration
Method : POST
Data example :
{
"firstName": "Bob",
"lastName": "Marton",
"email": "bob@gmail.com",
"password": "qwerty123"
}
Code : 200 OK
Content example :
{
"status": "registered"
}
Code : 400 Bad Request
Condition : If the JSON request fails validation.
Content example :
{
"errors": [
{
"field": "firstName",
"reason": "must have at least 2 characters"
},
{
"field": "lastName",
"reason": "must have at least 2 characters"
},
{
"field": "email",
"reason": "invalid email address"
},
{
"field": "password",
"reason": "must have at least 8 characters"
}
]
}
Code : 400 Bad Request
Condition : If the email already registered.
Content example :
{
"errors": [
{
"field": "email",
"reason": "this email is already registered"
}
]
}
- Authentication by email and password
URL : /api/login
Method : POST
Data example :
{
"email": "bob@gmail.com",
"password": "qwerty123"
}
Code : 200 OK
Content example :
{
"accessToken": "XXXXXX.YYYYYY.ZZZZZZ",
"refreshToken": "d19e6fcd-ee18-4b38-acae-d1f7b9109118"
}
Code : 401 Unauthorized
Condition : If 'email' and 'password' combination is wrong.
- Refresh user access token
URL : /api/refresh
Method : POST
Data example :
{
"refreshToken": "d19e6fcd-ee18-4b38-acae-d1f7b9109118"
}
Code : 200 OK
Content example :
{
"accessToken": "KKKKKK.NNNNNN.DDDDDD",
"refreshToken": "b1349089-8f71-464f-a0fa-f2675252693e"
}
Code : 400 Bad Request
Condition : If the refresh token is invalid or expired.
Content example :
{
"description": "invalid token"
}
Get user info from the database 'users' by id.
URL : /users/me
Method : GET
Requred header : Authorization: "Bearer <ACCESS_TOKEN>"
Code : 200 OK
Content example :
{
"id": "3490bad4-9af4-4329-9e8a-91ee2edf5ee8",
"email": "bob@gmail.com",
"firstName": "Bob",
"lastName": "Marton"
}
Code : 401 Unauthorized
Condition : If the access token is invalid or expired.