Fake Token API
Fake Node/Express API used to test token-based authentication.
Project Setup
- Fork/Clone
- Install Dependencies -
npm install
- Run -
npm start
Endpoints
- GET http://localhost:1337/ping
- POST http://localhost:1337/register
- POST http://localhost:1337/login
- GET http://localhost:1337/status
Requests
Register
Success:
$ curl http://localhost:1337/register \
-H "Content-Type: application/json" \
-X POST \
-d '{"email":"test@test.com", "password": "test"}'
{
"status": "success",
"token": "1234567"
}
Failure:
$ curl http://localhost:1337/register \
-H "Content-Type: application/json" \
-X POST \
-d '{"email":"not@right.com", "password": "test"}'
{
"status": "error"
}
Login
Success:
$ curl http://localhost:1337/login \
-H "Content-Type: application/json" \
-X POST \
-d '{"email":"test@test.com", "password": "test"}'
{
"status": "success",
"token": "1234567"
}
Failure:
$ curl http://localhost:1337/login \
-H "Content-Type: application/json" \
-X POST \
-d '{"email":"bad@email.com", "password": "test"}'
{
"status": "error"
}
Status
Success:
$ curl http://localhost:1337/status \
-H "Content-Type: application/json" \
-H "Authorization: Token 1234567"
{
"status": "success"
}
Failure:
$ curl http://localhost:1337/status \
-H "Content-Type: application/json" \
-H "Authorization: Token incorrect"
{
"status": "error"
}