Back to Browse

Refreshing Access Token When It Expires (Session + JWT)

4.9K views
Mar 13, 2025
30:21

๐Ÿ”ฅ Access Source Code, PPT & Notes here for Free : https://www.thapatechnical.com/2024/11/introduction-to-nodejs.html ๐Ÿ’ธ Get All My YouTube Videos' Source Code for just โ‚น249! Grab Now - https://thapatechnical.shop/source-code ----------------------------------------------------------------------- In this video, we are implementing a secure token refresh mechanism to handle expired or missing access tokens using JWT & Sessions. If the access token is invalid or has expired but the refresh token is still valid, we will generate new access & refresh tokens and store them securely in cookies. ๐Ÿ“บ Watch the complete Node.JS Playlist here :https://youtube.com/playlist?list=PLwGdqUZWnOp3KELplHtc-RnJ5xTUPqdgH&si=_ob8F88HYxCdspup You will learn: โœ… How access & refresh tokens work in authentication โœ… What happens when an access token expires โœ… Extracting tokens from cookies and verifying them โœ… Fetching session and user details from the database โœ… Generating a new access & refresh token dynamically โœ… Storing tokens securely in cookies โœ… Running & testing the authentication flow in a real app โœ… What happens to tokens when the user logs out ---------------------------------------------------------------- ๐Ÿš€ Boost Your Skills with these Pre-Requisite Videos: ๐Ÿ”— Best HTML Course - https://youtu.be/5ccq_nLHneE ๐Ÿ”— Best CSS Course - https://youtu.be/MSICFljRcb4 ๐Ÿ”— JavaScript Basics Course Part 1 - https://youtu.be/13gLB6hDHR8 ๐Ÿ”— JavaScript Advanced Course Part 2 - https://youtu.be/YwsOCN8woA8 ------------------------------------------------------------------------ ๐Ÿ’ธ Build Your Own E-commerce Website for Free! - https://www.thapatechnical.com/2024/03/build-complete-ecommerce-website-using.html ------------------------------------------------------------------------ โœŒ๏ธ Join Us! ๐Ÿš€ Become a Member: Unlock perks, free source code, and more Join Now : https://www.youtube.com/channel/UCwfaAHy4zQUb2APNOGXUCCA/join ๐Ÿ“ท Connect on Instagram: https://www.instagram.com/thapatechnical ๐Ÿ—จ๏ธ Join Our Discord Server: Hang out with fellow programmers Discord Link: https://discord.gg/MdScmCsua6 ------------------------------------------------------------------------ โŒ›TIMELINEโณ 0:00 - Introduction: Refreshing Access & Refresh Tokens ๐Ÿ“ 1:50 - Step-by-Step Guide to Refreshing Tokens ๐Ÿ“ 6:10 - What Happens When the Access Token Expires? (Theory) ๐Ÿ“ 7:02 - Understanding Database Structure for Refresh Tokens ๐Ÿ“ 8:15 - Get the Source Code for Free ๐Ÿ“ 9:30 - Where Is the verifyAuthentication Function Used? ๐Ÿ“ 10:40 - Extracting access_token and refresh_token from Cookies ๐Ÿ“ 12:45 - Handling Cases When an Access Token Is Present ๐Ÿ“ 14:25 - If the Access Token Is Missing or Invalid, Letโ€™s Refresh It ๐Ÿ“ 17:15 - Fetching the Session from the Database Using ID ๐Ÿ“ 20:00 - Fetching the User from the Database Using ID ๐Ÿ“ 22:00 - Generating a New Access & Refresh Token ๐Ÿ“ 24:35 - Storing Both Tokens Securely in Cookies ๐Ÿ“ 25:00 - Quick Recap of What We Did ๐Ÿ“ 26:40 - Running the App & Testing the Refresh Token Flow ๐Ÿ“ 29:00 - What Happens to Tokens When We Logout?

Download

0 formats

No download links available.

Refreshing Access Token When It Expires (Session + JWT) | NatokHD