E-Commerce Manager is a powerful Spring Boot application offering a comprehensive suite of REST APIs to
manage your e-commerce platform. This Java-based project includes functionalities for authentication,
customer and seller management, product catalog, shopping cart, and order processing.
-
Register as a Customer
Open Postman and make a POST request to register as a customer:
POST /.rest/auth/register/customer HTTP/1.1
Host: localhost:8080
Content-Type: application/json
{
"username": "customer",
"password": "customer"
}
-
Login as a Customer
Make a POST request to login as a customer:
POST /.rest/auth/login HTTP/1.1
Host: localhost:8080
Content-Type: application/json
{
"username": "customer2",
"password": "customer1"
}
You will receive a response with an access token:
{
"accessToken": "eyJhbGciOiJIUzM4NCJ9.eyJzdWIiOiJjdXN0b21lcjIiLCJpYXQiOjE3MTYzMzA5ODAsImV4cCI6MTcxNjMzNDU4MH0.NKby0j-8VmLosAdOqh1AqihHDGlxRtrbjyGuBNIRUGTg3Dy5wPOlAYcTM3UQqIvj",
"tokenType": "Bearer",
"expiresIn": 3600
}
-
Access Current Customer Information
Copy the access token and add an Authorization header of type Bearer token. Make a GET request like:
GET /.rest/customers/current HTTP/1.1
Host: localhost:8080
Authorization: Bearer eyJhbGciOiJIUzM4NCJ9.eyJzdWIiOiJjdXN0b21lcjIiLCJpYXQiOjE3MTYzMzA5ODAsImV4cCI6MTcxNjMzNDU4MH0.NKby0j-8VmLosAdOqh1AqihHDGlxRtrbjyGuBNIRUGTg3Dy5wPOlAYcTM3UQqIvj
You will receive a response like below:
{
"customerId": 1,
"firstName": null,
"lastName": null,
"mobile": null,
"email": null,
"username": "customer",
"password": "$2a$10$yCzB.FMyXMsyLenE96lgmeiUvMfwTNt6t3y4RwXO3GZuyZOsd.zty",
"createdAt": "2024-05-22T08:55:59.542793",
"updatedAt": "2024-05-22T08:55:59.542839",
"addresses": [],
"creditCards": [],
"role": {
"roleId": 1,
"name": "CUSTOMER",
"description": "Default customer role",
"createdAt": "2024-05-22T08:55:44.105505",
"updatedAt": "2024-05-22T08:55:44.105505"
}
}
-
Access Other Customer-Authenticated APIs
Use the access token to access other customer-authorized APIs such as managing your information,
cart, and orders.
You can also register and login as a seller and access seller-authenticated APIs.