An Interest In:
Web News this Week
- April 18, 2024
- April 17, 2024
- April 16, 2024
- April 15, 2024
- April 14, 2024
- April 13, 2024
- April 12, 2024
April 21, 2021 01:36 pm GMT
Original Link: https://dev.to/satishrajnale/jwt-authentication-3kgj
JWT-authentication
This project describes the steps involed in a authentication process between client & server using JWT tokens.
Find it on my Github repo :
Satish-Rajnale
First you need to generate some tokens
It's very easy just enter node and then the code in below image.
Then add these tokens in your .env file as ACCESS_TOKEN_PATH & REFRESH_TOKEN_PATH.
Onto the Requests part create a Requests.rest file as shown below.
You can use the extension Rest Client
in VsCode or you can also use Postman
, both are great but in this project I am using the entension.
- First make a request of
POST
for login on port:4000 On successfully making the request you will get the following response with tokens.
Copy the accessToken and paste it in your
GET
request's Auhtorization value. PORT:8080
- Copy the refreshToken and paste it in your
Post
request for token.PORT:4000
- When sent a request from
GET
method you will get the following response.###NOTE:There is a TimeLimit added and within that time limit you have to make the get request.For your convenience you can extend the time limit through your authuser.js code.
- When you send the
POST
request for token it generates the following access token which you can copy and paste in theGET
request. This will extend the user access/auth time. Basically you get access again.
- Now to delete the generated JWT token and logout the user use the
DELETE
request.
Original Link: https://dev.to/satishrajnale/jwt-authentication-3kgj
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To