Request:
# Sign up via x-www-form-urlencoded
curl localhost:3000/auth/signup -X POST -d "email=apollo@apollo.com&name=Apollo&username=apollo&password=apollo"
# Sign up via JSON
curl localhost:3000/auth/signup \
-X POST \
-H "Content-Type: application/json" \
-d '{
"email": "apollo@apollo.com",
"name": "Apollo",
"username": "apollo",
"password": "apollo"
}'Response:
{"token":"ey123456789.eyABCDEFGHIJKLMNOPQRSTUVWXYZ.ABC-XYZ"}%Request:
# apollo
curl localhost:3000/auth/signin -X POST -d "username=apollo&password=apollo"Response:
{"token":"ey123456789.eyABCDEFGHIJKLMNOPQRSTUVWXYZ.ABC-XYZ"}%Request:
req.body:/auth/is-authenticated -d "token=JWT_TOKEN"req.query:/auth/is-authenticated?token=JWT_TOKENreq.headers:Authorization: Bearer JWT_TOKEN
export TOKEN=ey123456789.eyABCDEFGHIJKLMNOPQRSTUVWXYZ.ABC-XYZ
# Body
curl http://localhost:3000/auth/is-authenticated -d "token=$TOKEN" -X POST
# Query
curl "http://localhost:3000/auth/is-authenticated?token=$TOKEN" -X POST
# Header
curl localhost:3000/auth/is-authenticated -X POST -H "Authorization: Bearer $TOKEN" -X POSTResponse:
trueNOTE: Use this only for checking.
Request:
curl localhost:3000/api/books \
-X POST \
-H 'Authorization: Bearer ey123456789.eyABCDEFGHIJKLMNOPQRSTUVWXYZ.ABC-XYZ' \
-H 'Content-Type: application/json' \
-d '{
"isbn": "121212",
"name": "Twelve",
"price": 12
}'Response:
{
"__v": 0,
"_id": "582c55169b62473608c0237e",
"updatedAt": "2016-11-16T12:46:14.812Z",
"createdAt": "2016-11-16T12:46:14.812Z",
"isbn": "121212",
"name": "Twelve",
"price": 12,
"owners": []
}