#An Node/Express Example of JWT (JSON Web Tokens)
This simple application is designed to demonstrate the principle of using JWT (JSON Web Tokens) as access tokens to protect an API.
For an overview of how it all works, read the tutorial - to follow shortly.
Obviously you'll need Node and npm, and you also need MongoDB installed and running.
##Installing and Setting Up
Install the project dependencies:
Ensure Mongod is running, and seed the database:
This will create a single user:
Run the application:
To get a token, make a
GET request to:
You'll need to set the headers:
Make a note of the access token in the returned JSON.
Now try making a
GET request to the following URL:
You should get a 401 Not Authorized.
However, if you set the access token; either as a
access_token or a header called
x-access-token you should see the following: