Monday, October 7

Tag: Authenticate Node ES6 API with JSON Web Tokens

Authenticate a Node ES6 API with JSON Web Tokens
Web Tricks

Authenticate a Node ES6 API with JSON Web Tokens

In this guide, we'll be implementing token based authentication in our own node.js A.P.I. using JSON web tokens. Plan of attack We'll begin by: Setting up our development environment and initializing our express server. Creating our first basic route and controller. Fleshing out our routes and controllers to add users and login users. Creating a route and controller that will handle getting all users. Finally, we'll Add middleware to protect our get users route by requiring a user to be an admin and to have a valid token. Validate that only an admin with a token can access the protected route. Sounds exciting? Let's get to it then. Setup Before we get started in earnest, we'll need to have a few things taken care of. Folder structure Here's what our folder...