JWT Authentication in NodeJS

  Рет қаралды 73,854

Piyush Garg

Piyush Garg

Жыл бұрын

► Watch this before: • Building Node.js Authe...
► Master NodeJS Playlist: • Master NodeJS
In this tutorial video, you will learn how to create a secure and robust authentication system for your Node.js application using JSON WEB TOKENS.
► Complete Full Stack Web Developer RoadMap 2023: • Complete Full Stack We...
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. It allows developers to run JavaScript on the server side, creating server-side applications with JavaScript.
► My Website: www.piyushgarg.dev
My Gears
► My Girlfriend: amzn.to/3WD6FRp
► Apple MacBook Laptop: amzn.to/3WBJgQn
► Anker USB Hub: amzn.to/3GhZSr0
► Blue Yeti Microphone: amzn.to/3YKZ9FT
► External 27” Monitor: amzn.to/3Vp3xaO
► Logitech MK295 Wireless Keyboard and Mouse: amzn.to/3DuL1bB
► Seagate Expansion 1TB External HDD: amzn.to/3QMm5Q8
► Tripod: amzn.to/3S4OwK4
► Ring Light: amzn.to/3YLf8DR
Disclaimer: All the links above are affiliate links.
Social Links
► Twitter - / piyushgarg_dev
► LinkedIn - / piyushgarg195
Video Titles
Securing Your Node.js App with User Authentication
Authentication 101: Implementing Login in Node.js
Adding User Login to Your Node.js Application
Authentication in NodeJS
Tags
#nodejs #authentication #javascript #expressjs #mongodb #mernstack #developer #api #https #server #javascriptinhindi #webdevelopment #webapp #realtimeapp #serverside #nonblockingio #tech

Пікірлер: 88
@tfnt3839
@tfnt3839 Жыл бұрын
I have seen the playlist of million subscriptions of the channel. but your teaching style and explanation is great.
@Javedboqo1
@Javedboqo1 7 ай бұрын
All of videos from this guy are very useful and amazing
@namannema3349
@namannema3349 2 ай бұрын
i like the way you explain by giving examples and your explanations are very user friendly
@pankaj8876
@pankaj8876 11 ай бұрын
Great explanation! 👌
@weforyouweb1165
@weforyouweb1165 Жыл бұрын
You are gem 🎉 You have very very deep knowledge of all things ❤🎉🎉
@joban_dhillonn
@joban_dhillonn 6 ай бұрын
bahot badiya exaple de kar samajiya sir apne secret key bhot confush tha thankuu
@amrExplore
@amrExplore 7 ай бұрын
Very nicely explained Piyush. ! question though, in case of refresh token does the secret on the server changes since the payload information would remain the same ? Wonderful JWT explnation
@PubG-dl5eh
@PubG-dl5eh Жыл бұрын
Great video sir👍
@100DDC
@100DDC 6 ай бұрын
wow, awesome bro
@ibntofajjal
@ibntofajjal Жыл бұрын
Keep Going Bro. You Doing Well
@satyampal7235
@satyampal7235 3 ай бұрын
Awesome explanation bhai 👌
@AfhamAdian
@AfhamAdian 5 ай бұрын
this is the best on internet
@vijenderkumar3034
@vijenderkumar3034 Жыл бұрын
Nice video
@SulavGhimireeee
@SulavGhimireeee 5 ай бұрын
Thanks bro
@mubasshirkhan1370
@mubasshirkhan1370 5 ай бұрын
Thank you bhai...... ❤🧡💛💚
@life-lessonn.
@life-lessonn. 6 ай бұрын
hello big brother what is the difference between jwt token vs express-session ?
@NKAnimations-mm2pp
@NKAnimations-mm2pp 5 күн бұрын
Sir I really like your videos but there are 2 problems which I am facing: 1. Your authentication videos are dependent on URLGeneration videos. 2. If someone face any error in the URL at any point he wont be able to continue until that error gets resolved. 3. Solution : if you could provide the source code then it would be easier for us to resolve our errors. 4. Solution : If you could make such videos which are not dependent on each other then it would be easier for us to understand each concept from the Scratch
@OTTStar334
@OTTStar334 12 сағат бұрын
source code are in the description
@najmulhasan5997
@najmulhasan5997 6 ай бұрын
thanks
@webdeveloper3529
@webdeveloper3529 Жыл бұрын
❤ sir your lectures are blessings for me... plz cover advanced nodejs caching, threading, etc...
@piyushgargdev
@piyushgargdev Жыл бұрын
Sure, Thanks :)
@harshrajsinha012
@harshrajsinha012 4 ай бұрын
i'm getting return done(new JsonWebTokenError('jwt malformed')); JsonWebTokenError: jwt malformed@@piyushgargdev this error
@lovelymusic3549
@lovelymusic3549 Жыл бұрын
Sir when you are starting a complete react JS course basic to advance any idea sir?
@mdebrahim2164
@mdebrahim2164 7 ай бұрын
helpfull
@ctet5470
@ctet5470 8 ай бұрын
Where we are calling getUser function?
@Black-Curtains
@Black-Curtains Жыл бұрын
Brother! as we are storing tokens with cookies. Someone can copy that token and log in, as you already demonstrated. Is it a secure way? कृपया मार्गदर्शन करें..
@piyushgargdev
@piyushgargdev Жыл бұрын
Good Point, I'll surely clear your doubt in next video ✨
@iamakashkumarram
@iamakashkumarram Жыл бұрын
JWT Authentication basic to Advance full cover karado sir.
@satyam94163
@satyam94163 Жыл бұрын
yes plz
@piyushgargdev
@piyushgargdev Жыл бұрын
Okay sure
@user-jc2is7zo4o
@user-jc2is7zo4o 11 ай бұрын
how can we encrypt jwt token? the way we encrypted the password!
@shivaverma85
@shivaverma85 3 ай бұрын
I dont know why everytime its giving me error as jwt malformed but i am writing the same code as you have written .. I have seen your all videos upto authentication and everything is fine but i dont know why as soon as i am using jwt its not working . i am working on it to find error from past 2 hours but its not working please help
@rakshitgupta1771
@rakshitgupta1771 2 ай бұрын
same problem aari hai bhai mujhe bhi solve hui kya???
@YashJain-hd2rs
@YashJain-hd2rs 2 ай бұрын
Same bro
@shubhamgupta-bl1tr
@shubhamgupta-bl1tr Жыл бұрын
But if we store sessions in database tab to problem ni hogi na in statefull
@Ayush37262
@Ayush37262 5 ай бұрын
He solved your doubt in the next video!!!
@hetpatel9503
@hetpatel9503 11 ай бұрын
👌
@as_if
@as_if 2 ай бұрын
<a href="#" class="seekto" data-time="270">4:30</a> difference between this token and the UID
@mma-dost
@mma-dost Жыл бұрын
Great video bhaiya there is something csrf is jwt secure with that hack ?
@piyushgargdev
@piyushgargdev Жыл бұрын
Added to my list, will surely make a video on it
@bm9code
@bm9code 6 ай бұрын
this is only video in which i saw that the use secret key in jwt ♥ thanks ♥
@mayanksinha1883
@mayanksinha1883 Ай бұрын
nodejs\urlshortener\service\auth.js:8 _id: user._id, ^ TypeError: Cannot read properties of undefined (reading '_id')
@pallabdandapat1866
@pallabdandapat1866 Ай бұрын
sir getting the below error : C:\Users\palla\Downloads\short-url-node\short-url-node ode_modules\jsonwebtoken\verify.js:70 return done(new JsonWebTokenError('jwt malformed')); ^ JsonWebTokenError: jwt malformed at module.exports [as verify] (C:\Users\palla\Downloads\short-url-node\short-url-node ode_modules\jsonwebtoken\verify.js:7<a href="#" class="seekto" data-time="17">0:17</a>) at getUser (C:\Users\palla\Downloads\short-url-node\short-url-node\service\auth.js:<a href="#" class="seekto" data-time="796">13:16</a>) at checkAuth (C:\Users\palla\Downloads\short-url-node\short-url-node\middlewares\auth.js:<a href="#" class="seekto" data-time="918">15:18</a>) at Layer.handle [as handle_request] (C:\Users\palla\Downloads\short-url-node\short-url-node ode_modules\express\lib outer\layer.js:9<a href="#" class="seekto" data-time="305">5:5</a>) at trim_prefix (C:\Users\palla\Downloads\short-url-node\short-url-node ode_modules\express\lib outer\index.js:3<a href="#" class="seekto" data-time="1693">28:13</a>) at C:\Users\palla\Downloads\short-url-node\short-url-node ode_modules\express\lib outer\index.js:28<a href="#" class="seekto" data-time="369">6:9</a> at Function.process_params (C:\Users\palla\Downloads\short-url-node\short-url-node ode_modules\express\lib outer\index.js:3<a href="#" class="seekto" data-time="2772">46:12</a>) at next (C:\Users\palla\Downloads\short-url-node\short-url-node ode_modules\express\lib outer\index.js:28<a href="#" class="seekto" data-time="10">0:10</a>) at cookieParser (C:\Users\palla\Downloads\short-url-node\short-url-node ode_modules\cookie-parser\index.js:7<a href="#" class="seekto" data-time="65">1:5</a>) at Layer.handle [as handle_request] (C:\Users\palla\Downloads\short-url-node\short-url-node ode_modules\express\lib outer\layer.js:9<a href="#" class="seekto" data-time="305">5:5</a>) Node.js v20.6.1 [nodemon] app crashed - waiting for file changes before starting...
@pratyushpragyey7002
@pratyushpragyey7002 Ай бұрын
function getUser(token){ if(!token) return null; try { return jwt.verify(token ,secret); } catch (error) { return null; } } use this function instead of what you've written
@pallabdandapat1866
@pallabdandapat1866 Ай бұрын
@@pratyushpragyey7002 yes sir , i have done the same thing , thank you.
@mayanksinha1883
@mayanksinha1883 Ай бұрын
@@pratyushpragyey7002 thanks mannn
@shi-nee7966
@shi-nee7966 Жыл бұрын
sir i am getting error "jwt malformed" i tried matching codes, also searched on stackoverflow but just couldnt solve the error...please help if you know...i will update if i get the solutain
@dishantsingh5790
@dishantsingh5790 Жыл бұрын
i got the same error just now, restart ur server then dont directly go to "/" route , firstly clear cookie from Browser then go to the login page , login as user , then everythng will work fine
@daniyalghani4857
@daniyalghani4857 9 ай бұрын
i got the same error thank you brother @@dishantsingh5790
@harshrajsinha012
@harshrajsinha012 4 ай бұрын
it's not working bro @@dishantsingh5790
@usmanmunir5241
@usmanmunir5241 4 ай бұрын
I am still getting error ​@@dishantsingh5790
@usmanmunir5241
@usmanmunir5241 4 ай бұрын
How you resolve this error?? @shi-nee7966
@20_omkar_kadu57
@20_omkar_kadu57 Жыл бұрын
jwt itma hi hota he ya aur bhi kuch he
@MrBlazzerBoy
@MrBlazzerBoy 5 ай бұрын
Please mention it's Hindi in title.
@dhruvbandi6633
@dhruvbandi6633 7 ай бұрын
bro where is the code
@deepanshuaggarwal5181
@deepanshuaggarwal5181 10 ай бұрын
how on changing payload with wrong email and right secret key, we logged in at <a href="#" class="seekto" data-time="640">10:40</a>
@Ayush37262
@Ayush37262 5 ай бұрын
Did you got the answer?? I think maybe because we have already entered the correct email and password in the beginning...
@codingwave56
@codingwave56 6 ай бұрын
Hmne Information (Object) ko JWT ki madad se bina Secret key bhi generate kar diya to ye secret key kiss kam ki? Plz Reply Sir...
@utube6044
@utube6044 6 ай бұрын
kaha pe?
@varunchakraborty6020
@varunchakraborty6020 5 ай бұрын
I don't know if you got the soln or no, but Secret key token me changes krne ke liye h n ki use read krne ke liye
@codingwave56
@codingwave56 5 ай бұрын
@@varunchakraborty6020 Yes, Got it 👍🏻 Thanks
@utube6044
@utube6044 5 ай бұрын
@@varunchakraborty6020 matlab ki dekhne k liye ki ye token meri secret key se bana hai ki nai?
@varunchakraborty6020
@varunchakraborty6020 5 ай бұрын
@@utube6044 hn mtlb agr kisi aur ne changes krdiya token me, to mai verify krskta hu, ki final token mere secret key se bni h ya nhi
@rishabhraj8233
@rishabhraj8233 6 ай бұрын
hey I am here on 1st jan anybody else?
@user-hn4lc1cv3p
@user-hn4lc1cv3p 2 ай бұрын
someone has its source code
@sudhanshugautam425
@sudhanshugautam425 7 ай бұрын
let say you want to make this project open source, but in the backend itself you shared the secret key and using that anyone can get make fake token????
@Ayush37262
@Ayush37262 5 ай бұрын
I think we will store the secret key in the .env file
@ShivendraPratap524
@ShivendraPratap524 Жыл бұрын
What next?????
@piyushgargdev
@piyushgargdev Жыл бұрын
We will cover advance concepts while building projects, No video for today!
@ShivendraPratap524
@ShivendraPratap524 Жыл бұрын
@@piyushgargdev matlab ab projects hi projects ayenge
@ShivendraPratap524
@ShivendraPratap524 Жыл бұрын
One more request react ke sath integrate karle bhi ek project, fir chain se jinda rahenge
@ShivendraPratap524
@ShivendraPratap524 Жыл бұрын
@@piyushgargdev aur haa videos ki continuity yahi rakhiyega sir
@AtharvJoshi-jc7ow
@AtharvJoshi-jc7ow 13 күн бұрын
then why the heck IRCTC uses session😂 it loggs you out at the last second of your attempt to book tatkal ticket💩
@anandshete9170
@anandshete9170 8 күн бұрын
bhai ham agar hot to ham khud hi acche khase website bana lete yarr inko kon bataye abb saste saste developers use kiye hai inhone
@hemobhai1
@hemobhai1 4 ай бұрын
Ek hi video me bana diya Karo na warna bataya hi mat karo pahle ye dekho tab wo dekho aadmi yaha sikhne aata hai ki tumlog ka views badhane
@mujibulhaquetanim
@mujibulhaquetanim 4 ай бұрын
Bhai, have some patience. it is not a paid course.
@user-nt8cn3pp5f
@user-nt8cn3pp5f 4 ай бұрын
same bro mujhe bhi bhout gussa aata hai
@proudtobeindian27
@proudtobeindian27 3 ай бұрын
Bhai mat aaya kar ehsaan na kar us par, ek to free main pada ra upar se tu attitude dikha ra, scroll kar aur dusare ko dekh na
@shivajikapale2336
@shivajikapale2336 2 ай бұрын
Bhai bahut badiya padha raha hai banda free mai... Pura videos dekho nahi to kuch mat dekho
@quick-bytes
@quick-bytes Ай бұрын
Separate video better hai warna bohot long ho jata woh video na itna tum ya koi bhi samaj kr digest kr pata atleast iska part 1 video khtm hua hoga tb logo ne practice krne ka try kra hoga Netflix pr binge watch krne nahi aaye ho sikhne aaye ho tum yaha pr 🙂
What are Cookies in NodeJS?
30:35
Piyush Garg
Рет қаралды 45 М.
Building Node.js Authentication from Scratch
39:09
Piyush Garg
Рет қаралды 115 М.
3M❤️ #thankyou #shorts
00:16
ウエスP -Mr Uekusa- Wes-P
Рет қаралды 7 МЛН
What Is JWT and Why Should You Use JWT
14:53
Web Dev Simplified
Рет қаралды 1,1 МЛН
Token vs Session Authentication | Authentication Explained!!!
15:19
Server Side Rendering with EJS and Node.JS
25:24
Piyush Garg
Рет қаралды 55 М.
What is JWT ? JSON Web Token Explained - YouTube
5:13
Techno Saviour
Рет қаралды 45 М.
Authorization in NodeJS
19:33
Piyush Garg
Рет қаралды 29 М.
What is JWT? JSON Web Tokens Explained (Java Brains)
14:53
Java Brains
Рет қаралды 1 МЛН