JWT Authentication with Access Tokens & Refresh Tokens In Node JS

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ต.ค. 2024
  • What's up guys welcome to my channel. We all know most important feature in every application is authentication. To make that authentication much more secured and make better user experience we need to use refresh and access token based authentication in your app. You might be thinking what is refresh token?, why should we use?, how should we use ?
    First let's take a look at older way of authenticating user which is called token based authentication. When user logged in we send a access token which is valid for certain time. When that token expires we have to ask user again to login, Which is tedious user experience. To solve that problem we have to use refresh token.
    A refresh token is nothing but a access token but it has life time about 1 or 2 months. Access token has expire time about 10 to 15 minutes. Whenever this access token expire. we don't ask user to login again to get new access token instead we send refresh token to the server here we verify that token and send new access token to the client. with this method user don't have to login again and again. this makes user experience much more easier to user.
    To know how to implement refresh token in node js watch this video.
    I hope you learn something new today. If you like my work subscribe to my channel and like this video.
    Source Code = github.com/cyb...
    ╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
    ║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
    ╠╗║╚╝║║╠╗║╚╣║║║║║═╣
    ╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
    Tags = {jwt authentication node js, jwt node js, jwt node js express, json web token authentication node js, jwt auth express, jwt auth node js express, refresh tokens, mern stack, user authentication, node js authentication, refresh token authentication, access token, refresh token, TomDoesTech, yoursTruly }
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 36

  • @daniellobo4950
    @daniellobo4950 2 ปีที่แล้ว +2

    I'm a junior developer and your video was so fast that it gave me a headache. I had to take a pill and lie down for a bit. But I am actually here to thank you! This was ** THE BEST ** video I found on TH-cam about JWT Access and Refresh tokens. For the past three days I have been watching videos on the subject and now I can finally stop. Your video taught me everything I needed to know and much, much more. By the way, your code is beautiful. Thank you very much, Sir.
    I have liked the video and subscribed to the channel. 😊🙏👏

  • @sandeepkamra6177
    @sandeepkamra6177 2 หลายเดือนก่อน

    it was an amazing video,even I learnt many new things like, type:module in package.json, enum in models, joi, password strength and a few more things. One of the main thing, video is neat and clean and easy understandable.

  • @infinioda108
    @infinioda108 7 หลายเดือนก่อน

    great tut sir, one of the best YT teachers

  • @justojonathan
    @justojonathan ปีที่แล้ว +5

    Why do you store refresh tokens in database if JWTs are self contained?

    • @GhostNikki
      @GhostNikki 3 หลายเดือนก่อน

      Yes, same question? @CyberWolves ?

  • @Abhiabhi-qj8xv
    @Abhiabhi-qj8xv 5 หลายเดือนก่อน

    Nice explanation , do watch with patience guys .

  • @sandeepkamra6177
    @sandeepkamra6177 2 หลายเดือนก่อน

    I also want to upload my apis on any server, I do not know which free server will be best, however, I am thinking to upload APIs on vercel. can you please create or send a video link for same?

  • @fabinhorockfabinho
    @fabinhorockfabinho 2 ปีที่แล้ว

    Thank you so much! This is the best video ever! Don't stop, guy! You rock!

  • @sandeepkamra6177
    @sandeepkamra6177 2 หลายเดือนก่อน

    to be frank, I was searching to integrate the refresh token api in react js and luckly I find your this video which learnt me many things. can you send me the link if you have create a video to integrate refresh token in react js please.

  • @shareeqrashid464
    @shareeqrashid464 2 ปีที่แล้ว

    After Creating The AccessToken when User Logins, where should we store the accessToken and Refresh Token? HttpOnlyCookie or LocalStorage?

    • @shareeqrashid464
      @shareeqrashid464 2 ปีที่แล้ว

      Can we Create 2 token, store 1 in LocalStorage and one in httpOnyCookie, get both of them in server and then validate both of them instead, Would this improve the security of our website?

    • @VarunDeva23
      @VarunDeva23 2 ปีที่แล้ว

      Same doubt i have
      Till now i didn't get the answer
      Where to store both the tokens in frontend

  • @sandeepkamra6177
    @sandeepkamra6177 2 หลายเดือนก่อน

    Can you please send a link for reset password video in node js or a playlist with JWT.

  • @vikasni95
    @vikasni95 ปีที่แล้ว

    One suggestion plz avoid adding background music, it really divert the mind

  • @BunkarCode
    @BunkarCode 2 ปีที่แล้ว

    awesome tutorial.. please merge this tutorial with your email based authentication and password reset with email video😊🙏

  • @babu32123
    @babu32123 11 หลายเดือนก่อน

    Refresh token not expire after 30 days ?not delete in mongodb

  • @glorieus27
    @glorieus27 2 ปีที่แล้ว

    Great tutorials. Please make for the client side using Angular or React. Thankyou

  • @nalcapital
    @nalcapital 2 ปีที่แล้ว +1

    Thank you guy. Its usefull. It helped for me

  • @aceguevarra2893
    @aceguevarra2893 ปีที่แล้ว

    what font are you using?

  • @infinioda108
    @infinioda108 7 หลายเดือนก่อน

    coding like brad traversy media bro, basically simply great

  • @Jimmy-zt5io
    @Jimmy-zt5io ปีที่แล้ว

    Thanks for the video, does this work if the user refresh the page?, before i had an issue in which i used httponly cookie (i was using mern stack), but the problem is that if i refreshed the page the user cannot be persisted since im not keeping the jwt in the localstorage, so now i wanna use access tokens + refresh tokens which is said to be secure

  • @sagarandaryal
    @sagarandaryal ปีที่แล้ว

    Can I get this vscode theme extension?

  • @raichand70
    @raichand70 ปีที่แล้ว

    Please make the client side of this tutorial.

  • @BecodemyOfficial
    @BecodemyOfficial ปีที่แล้ว

    Good Explanation💝

  • @meetpokal8324
    @meetpokal8324 6 หลายเดือนก่อน

    Where we can find secret key for access and refresh token? Anyone who know please help me

    • @JetProduction4579
      @JetProduction4579 3 หลายเดือนก่อน

      both keys are kept in .env file

  • @utsavbhattarai5707
    @utsavbhattarai5707 2 ปีที่แล้ว

    informative video love it🔥🔥

  • @maximocipriani
    @maximocipriani 2 ปีที่แล้ว

    Excelent. Thankyou

  • @krishnapurwar1738
    @krishnapurwar1738 2 ปีที่แล้ว

    please add this on frontend

  • @wolverine_d_king9422
    @wolverine_d_king9422 ปีที่แล้ว

    Iska frontend kaha hai

  • @awaisaslam9022
    @awaisaslam9022 2 ปีที่แล้ว +1

    I tried to follow and understand your video whole day,,, but I couldn't....
    please focus to teach us code + LOGIC equally...
    otherwise we end up overwhelmed and demotivated

    • @beautyofworld1700
      @beautyofworld1700 ปีที่แล้ว

      he has already provided the good video. please first google it out how the access token and refresh token works then come to this video for how to implement in node js

  • @chaimanaoueni9965
    @chaimanaoueni9965 2 ปีที่แล้ว

    The link of the source code doesn't exist