Closed rkpatra201 closed 9 months ago
If you have finished your signup, then
curl --location 'localhost:8080/user/login' \ --header 'Content-Type: application/json' \ --data-raw '{ "email":"abcd@email.com", "password": "abc@123" }'
From the above postman we can see below reponse:
{ "type": "ENCODED", "value": "YzJjMDgzODMtNWE2Ni00YjY1LTkzMmYtYWE2ZTllN2UxNjkw" }
copy the value i.e. : YzJjMDgzODMtNWE2Ni00YjY1LTkzMmYtYWE2ZTllN2UxNjkw
We will use above copied token in subsequent request as shown below.
For example, I want to access the endpoint: GET http://localhost:8080/cart in postman
So in postman under headers section I will add a header called X-AUTH-TOKEN and value would above copied value.
curl --location 'localhost:8080/cart' \ --header 'X-AUTH-TOKEN: YzJjMDgzODMtNWE2Ni00YjY1LTkzMmYtYWE2ZTllN2UxNjkw'
Now if I dont pass token then I will get 401 UNAUTHORIZED reponse, as shown below.
See I have disabled the X-AUTH-TOKEN header in the screenshot.
Hence always pass the token after doing login, otherwise it will give 401 UNAUTHORIZED error.
If you have finished your signup, then
Obtain token: Login using user email and password.
From the above postman we can see below reponse:
copy the value i.e. : YzJjMDgzODMtNWE2Ni00YjY1LTkzMmYtYWE2ZTllN2UxNjkw
Use token: Use token with header X-AUTH-TOKEN
We will use above copied token in subsequent request as shown below.
For example, I want to access the endpoint: GET http://localhost:8080/cart in postman
So in postman under headers section I will add a header called X-AUTH-TOKEN and value would above copied value.
Now if I dont pass token then I will get 401 UNAUTHORIZED reponse, as shown below.
See I have disabled the X-AUTH-TOKEN header in the screenshot.
Hence always pass the token after doing login, otherwise it will give 401 UNAUTHORIZED error.