React Login Authentication with JWT Access, Refresh Tokens, Cookies and Axios

Dave Gray โ€ข January 28, 2022
Video Thumbnail

About

Web Development tutorials with full courses on HTML, CSS, JavaScript, React, Node.js and more! My goal is to help you learn how to build the web. Teaching helps me learn, too. I work full-time as a Solutions Architect / Developer and part-time as a university web dev instructor. Thank you for subscribing, supporting my channel and sharing the videos you think may help others. Keep striving for progress over perfection. And a little progress every day goes a very long way. Milestones: July 20, 2020 - 1st video Jan 1, 2021 - 1k subs April 2021 - 4k watch hours Nov 2021 - 10k subs Jan 21, 2022 - Video at 100k views Feb 16, 2022 - 100k watch hours Feb 19, 2022 - 1m views Dec 13, 2022 - 100k subs Dec 2022 - Over 1m views in 1 month April 7, 2023 - 10m views May 26, 2023 - 1m watch hours Sept 22, 2023 - Video at 1m views Dec 25, 2023 - 250k subs

Video Description

Web Dev Roadmap for Beginners (Free!): https://bit.ly/DaveGrayWebDevRoadmap React Login Authentication with JWT uses access and refresh tokens to authenticate users. You will use Axios and learn how to handle and store JWT access and refresh tokens. Also, why secure cookies are better than localStorage. ๐Ÿ’– Support me on Patreon โžœ https://patreon.com/davegray โญ Become a full-stack web dev with Zero To Mastery Courses: - Advanced React: https://bit.ly/AdvReactDev - Jr to Senior Web Dev Roadmap: https://bit.ly/WebDevRoadmap-JrtoSr - Master FAANG Coding Interviews: https://bit.ly/FAANGInterview ๐Ÿšฉ Subscribe โžœ https://bit.ly/3nGHmNn ๐Ÿš€ React JS for Beginners full course - 9 hours: https://youtu.be/RVFAyFWO4go ๐Ÿ‘€ React Login tutorial series playlist: https://www.youtube.com/playlist?list=PL0Zuz27SZ-6PRCpm9clX0WiBEMB70FWwd ๐Ÿ”— Starter Source Code: https://github.com/gitdagray/react_protected_routes ๐Ÿ”— Completed Source Code: https://github.com/gitdagray/react_jwt_auth ๐Ÿ“ฌ Course Updates โžœ https://courses.davegray.codes/ React Login Authentication with JWT Access, Refresh Tokens, Cookies and Axios (00:00) Intro (00:41) Welcome Discussion (01:43) JWT Authentication (04:37) Update NPM Packages (05:40) Users Component (08:38) Users Request (13:27) Requests Needs the Access Token (14:25) useRefreshToken hook (17:55) Testing useRefreshToken (20:05) Private Axios Instance (22:31) useAxiosPrivate with interceptors (32:28) Updating the Users component (35:11) Handling an expired refresh token (39:56) JWT Strategy Revisited โ˜• Buy Me A Coffee: https://www.buymeacoffee.com/davegray The React Login Authentication Series: 1) React Register Form with Validation, Axios and a11y: https://youtu.be/brcHK3P6ChQ 2) React User Login and Authentication with Axios: https://youtu.be/X3qyxo_UTR4 3) React Protected Routes | Role-Based Authorization: https://youtu.be/oUZjO00NkhY 4) This video! ๐Ÿ”— Node JS Full Course (with source code) for building the backend REST API that will receive your form submissions: https://youtu.be/f2EqECiTBL8 ๐Ÿ”— React Router Version 6 in 20 minutes: https://youtu.be/XBRLVRjZ3CQ ๐Ÿ”— FontAwesome for React: https://fontawesome.com/v5.15/how-to-use/on-the-web/using-with/react ๐Ÿ”— RegExr for Regular Expressions: https://regexr.com/ ๐Ÿ“š JWT References: Intro to JSON Web Tokens: https://jwt.io/introduction All You Need to Know About Storing JWT in the Frontend: https://dev.to/cotter/localstorage-vs-cookies-all-you-need-to-know-about-storing-jwt-tokens-securely-in-the-front-end-15id Cross-Site Scripting (XSS): https://owasp.org/www-community/attacks/xss/ Cross-Site Request Forgery (CSRF): https://owasp.org/www-community/attacks/csrf ๐Ÿ“š Accessible Form References: WebAIM.org - Advanced Forms: https://webaim.org/techniques/forms/advanced WebAIM.org - Form Validation: https://webaim.org/techniques/formvalidation/ MDN - Aria Attributes: aria-invalid: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-invalid_attribute aria-describedby: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby aria-live: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-live aria-label: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label ๐Ÿ”— ES7 React JS Snippets Extension for VS Code: https://marketplace.visualstudio.com/items?itemName=dsznajder.es7-react-js-snippets ๐Ÿ”— React Dev Tools Extension for Chrome: https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi ๐Ÿ“š References: ReactJS Official site: https://reactjs.org/ React Wikipedia: https://en.wikipedia.org/wiki/React_(JavaScript_library) React Jobs: https://www.ziprecruiter.com/candidate/search?search=react&location= โœ… Follow Me: Github: https://github.com/gitdagray Twitter: https://twitter.com/yesdavidgray LinkedIn: https://www.linkedin.com/in/davidagray/ Blog: https://yesdavidgray.com Reddit: https://www.reddit.com/user/DaveOnEleven Was this tutorial about React Login Authentication with JWT Access and Refresh Tokens helpful? If so, please share. Let me know your thoughts in the comments. #react #login #authentication

You May Also Like

Level Up Your Gear Essentials

AI-recommended products based on this video

Loading...
COTUBLR 31 Inch Computer Desk, Home Office Desk, Simple Modern Small Desk for Bedroom, Writing Desk with Storage Bag, Study Table for Students, Grey Oak

COTUBLR 31 Inch Computer Desk, Home Office Desk, Simple Modern Small Desk for Bedroom, Writing Desk with Storage Bag, Study Table for Students, Grey Oak

(180)
$64.99
FREE delivery Thu, Jun 26
Loading...
Swiss Outdoors Rain Fly Tarp | Waterproof Tent Shelter Canopy | Lightweight Easy Setup for Hammock, Backpacking or Camp Gear | Premium Quality 12 x 9 ft |, Green Army

Swiss Outdoors Rain Fly Tarp | Waterproof Tent Shelter Canopy | Lightweight Easy Setup for Hammock, Backpacking or Camp Gear | Premium Quality 12 x 9 ft |, Green Army

(66)
$46.62
FREE delivery Thu, Jun 19
Loading...
Ball Head Manbily Tripod Head Metal Aluminum Body 360ยฐ Panoramic Monopod Head with Extra Arca Swiss Quick Release Plate, Load up to 17.6lbs/8kg,Camera Head for DSLR, Camcorder, Slider (Red)

Ball Head Manbily Tripod Head Metal Aluminum Body 360ยฐ Panoramic Monopod Head with Extra Arca Swiss Quick Release Plate, Load up to 17.6lbs/8kg,Camera Head for DSLR, Camcorder, Slider (Red)

(274)
$85.26$77.52
FREE delivery Jun 17 - 19Only 10 left in stock.
Loading...
koolehaoda Professional Gimbal Head Tripod Head Aluminum Alloy Heavy Duty 360ยฐ Panoramic with Arca-Swiss Standard 1/4 inch QR Plate for DSLR Cameras up to 55.11lbs/25kg. (GH-3)

koolehaoda Professional Gimbal Head Tripod Head Aluminum Alloy Heavy Duty 360ยฐ Panoramic with Arca-Swiss Standard 1/4 inch QR Plate for DSLR Cameras up to 55.11lbs/25kg. (GH-3)

(63)
$168.98
FREE delivery Thu, Jun 19
Loading...
koolehaoda L Shape Camera Bracket, Video Vertical Shooting Quick Release Plate L Stand Arca Swiss Compatible for Tripod Head Ballhead DSLR Camera

koolehaoda L Shape Camera Bracket, Video Vertical Shooting Quick Release Plate L Stand Arca Swiss Compatible for Tripod Head Ballhead DSLR Camera

(87)
$23.98
FREE delivery Thu, Jun 19 on your first order
Loading...
LICAEVEY 84MP Digital Camera, 6K 18X Optical Zoom Wide Angle DSLR Camera, 1500mAh Li Battery 3 Inch LCD Vlogging Camera for Travel Recording Video (Black)

LICAEVEY 84MP Digital Camera, 6K 18X Optical Zoom Wide Angle DSLR Camera, 1500mAh Li Battery 3 Inch LCD Vlogging Camera for Travel Recording Video (Black)

(0)
$124.30
FREE delivery Aug 19 - 29
Loading...
SanDisk 64GB Extreme PRO SDXC UHS-I Memory Card - C10, U3, V30, 4K UHD, SD Card - SDSDXXU-064G-GN4IN

SanDisk 64GB Extreme PRO SDXC UHS-I Memory Card - C10, U3, V30, 4K UHD, SD Card - SDSDXXU-064G-GN4IN

(71,074)
$21.99$16.59
FREE delivery Sun, Aug 10 on your first order
500+ bought in past month
Loading...
SanDisk 128GB Extreme PRO SDXC UHS-I Memory Card - C10, U3, V30, 4K UHD, SD Card - SDSDXXD-128G-GN4IN
Best Seller

SanDisk 128GB Extreme PRO SDXC UHS-I Memory Card - C10, U3, V30, 4K UHD, SD Card - SDSDXXD-128G-GN4IN

(71,074)
$29.99$26.61
FREE delivery Sun, Aug 10 on your first order
4K+ bought in past month
Loading...
Lexar 128GB Micro SD Card, microSDXC UHS-I Flash Memory Card with Adapter - Up to 100MB/s, A1, U3, Class10, V30, High Speed TF Card

Lexar 128GB Micro SD Card, microSDXC UHS-I Flash Memory Card with Adapter - Up to 100MB/s, A1, U3, Class10, V30, High Speed TF Card

(26,884)
$18.99
FREE delivery Wed, Aug 20 on your first order
5K+ bought in past month
Loading...
koolehaoda Professional Gimbal Head Tripod Head Aluminum Alloy Heavy Duty 360ยฐ Panoramic with Arca-Swiss Standard 1/4 inch QR Plate for DSLR Cameras up to 55.11lbs/25kg. (GH-3)

koolehaoda Professional Gimbal Head Tripod Head Aluminum Alloy Heavy Duty 360ยฐ Panoramic with Arca-Swiss Standard 1/4 inch QR Plate for DSLR Cameras up to 55.11lbs/25kg. (GH-3)

(63)
$168.98
FREE delivery Thu, Jun 19
Loading...
Ball Head Manbily Tripod Head Metal Aluminum Body 360ยฐ Panoramic Monopod Head with Extra Arca Swiss Quick Release Plate, Load up to 17.6lbs/8kg,Camera Head for DSLR, Camcorder, Slider (Red)

Ball Head Manbily Tripod Head Metal Aluminum Body 360ยฐ Panoramic Monopod Head with Extra Arca Swiss Quick Release Plate, Load up to 17.6lbs/8kg,Camera Head for DSLR, Camcorder, Slider (Red)

(274)
$85.26$77.52
FREE delivery Jun 17 - 19Only 10 left in stock.
Loading...
Heavy Duty Tripod Gimbal Head, Aluminum Alloy 360ยฐ Panorama Gimbal with for Arca Swiss Standard Quick Release Plate and Bubble Level, with 1/4 Inch and 3/8 Inch Screws

Heavy Duty Tripod Gimbal Head, Aluminum Alloy 360ยฐ Panorama Gimbal with for Arca Swiss Standard Quick Release Plate and Bubble Level, with 1/4 Inch and 3/8 Inch Screws

(0)
$202.00
FREE delivery Jun 27 - Jul 10
Loading...
NEEWER Zf Handgrip L Shape Grip for Nikon Z f, Ultra Thin Retro Formfitting Camera Mounting Baseplate with Handle & Aluminum Shutter Button Cap, Compatible with Arca Swiss Tripod Fluid Head, CA073

NEEWER Zf Handgrip L Shape Grip for Nikon Z f, Ultra Thin Retro Formfitting Camera Mounting Baseplate with Handle & Aluminum Shutter Button Cap, Compatible with Arca Swiss Tripod Fluid Head, CA073

(236)
$33.99
FREE delivery Thu, Jun 19 on your first order