Tutorial: LoopBack 4 API with JWT Authentication

1st step: Install node.js the Todo example and install the JWT authentication extension

npm init
lb4 example todo
cd loopback4-example-todo
npm i --save @loopback/authentication @loopback/authentication-jwt

2nd step: Create the Controller for login

3rd step: Associate the JWT component in the application placing the code in the application.ts file

4th step: Add endpoints in the user.controller.ts file

5th step: Protect the Todo APIs in the todo.controller.ts file

6th step: Execute the API using the following server http://127.0.0.1:3000/explorer/

7th step: Sign up using the POST/signup API

8th step: Login using the POST /users/login API, that is, copy the respective ID that is found in the response body

Last step: Go to the top of the API Explorer, click the “Authorize” button, paste the ID and click Authorize

And this is it!!

--

--

--

Finalist student in Computer Engineering

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Fix to The “npm ERR! Object for dependency @Babel/generator is empty” Error

How To Make your own slider on ReactJS

Webpack with PostCSS

Why you should use Paid Solutions for sending Emails.

Palindrome Number LeetCode Cheat Sheet Javascript Solution

Creating your own React Hooks

React Logo on black background

Turning on Google Analytics with React and React Router

How to Upload Files to AWS S3 From NextJS App

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Afonso Antunes

Afonso Antunes

Finalist student in Computer Engineering

More from Medium

StaticResource & DynamicResource in Xamarin Forms

Clean Code: Vue.js Edition

Entity Bundle Classes

Test-Driven Development — What, How, and Why?