Auth with JWT

Authentication

You can do login by sending an object like the following to /auth/login/

[POST] https://api.escuelajs.co/api/v1/auth/login
{
  "email": "john@mail.com",
  "password": "changeme"
}

The response is a JWT Token, like this:

{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImpvaG5AbWFpbC5jb20iLCJzdWIiOjEsImlhdCI6MTY0Nzg3NTY5MywiZXhwIjoxNjQ3ODc5MjkzfQ.yrPEqd3YEgmxwEXq3SFy33bhV2jcIKc8BMGZfwuWyHM"
}

Get user with session

You can get the profile the current user with session if in the headers include the Authorization key with the value Bearer {your token} to /auth/profile

[GET] https://api.escuelajs.co/api/v1/auth/profile
{
  "id": 1,
  "email": "john@mail.com",
  "password": "changeme",
  "name": "Jhon",
  "role": "customer"
}
Platzi Fake Store API - Simple and powerful API for your e-commerce prototype | Product Hunt