The API exposes 2 resources. - Users - For authentication - Products - For authenticated CRUD operations.
http:https://localhost:3000/explorer
API Endpoint: http:https://localhost:3000/api/users/login HTTP Verb: POST Content Type: application/json
{
"username": "mindfire",
"password": "mindfire
}
{ "id": "UqFZVcGGrTX1pXWFmAyBpenb4U1pFNn4ExE0IIvEjTl69nvyUroELBJbvErGhGi9", "ttl": 1209600, "created": "2019-01-15T11:07:06.569Z", "userId": 1 }
The "id" field in the above response is the Access Token to be used in the subsequent requests to other API endpoints. Hence, the Access Token in this case will be UqFZVcGGrTX1pXWFmAyBpenb4U1pFNn4ExE0IIvEjTl69nvyUroELBJbvErGhGi9
The subsequent API endpoints will need Access Token to be used in the Headers. So, add the following header. Header: x-access-token Value: <your_access_token> For example, x-access-token: UqFZVcGGrTX1pXWFmAyBpenb4U1pFNn4ExE0IIvEjTl69nvyUroELBJbvErGhGi9
GET - http:https://localhost:3000/api/products GET - http:https://localhost:3000/api/products/:product_id POST - http:https://localhost:3000/api/products PUT - http:https://localhost:3000/api/products/:product_id DELETE - http:https://localhost:3000/api/products/:product_id
Example GET response { "name": "Apple iPhone X", "price": 7000, "rating": 4, "id": 1 }
POST - http:https://localhost:3000/api/users/login Header - x-access-token: <your_access_token>