How Interceptors EASILY implement Refresh Tokens in Angular!

preview_player
Показать описание
How Interceptors implement Refresh Tokens EASILY In Angular!
How Interceptors easily implement Refresh Tokens in Angular!

Using refresh tokens with json web tokens is a great way to keep your application a bit more secure. What happens though when your client side is trying to access api resources and you keep receiving 401 errors? Well in this case we need to try and get new tokens for the user, but without causing them the hassle of them needing to sign in. So in Angular we can leverage the power of interceptors to automatically attempt to get new tokens for the user and conveniently keep them in the application. So in this video i want to show you guys all the frontend code needed to make that work in an interceptor. We are using the same Angular app from the previous tutorials and if you haven't seen those other videos the link is below.

#RefreshTokens #Angular #Interceptor

TimeStamps
----------------------------
00:00 Intro
00:22 Creating the Interceptor File
00:34 What Are Interceptors Used For?
01:17 Explaining The Project We Are Using
02:50 Coding The Interceptor To Work With Refresh Tokens
07:37 Testing The Refresh Tokens & Interceptor
Рекомендации по теме
Комментарии
Автор

Will you guys be using Refresh Token in your next app? Why or Why Not? Please drop a like on this video if u found it helpful!

IsraelQuiroz
Автор

its possible to automatically refresh token and retry the request? if yes how to do that?

JoaoRoberto-mmqj
Автор

Sir actually I use fetch method intense of http ...how i use interceptor for refresh token ...plz reply

jlsvggp
Автор

Hello sir actually i use fetch method in using angular instance of http ..then how i use interceptor ? For fetch method

jlsvggp
Автор

The way i've done it is instead of adding a ctr variable, we check req.url if its is a refresh token request. But i guess both ways work!

IcedCupcakes
Автор

Whould it be possible to retry the request after retrieving a new access token? I think that this is necessary. This whould be the optimal in user experience, you dont want the user to receive a notification that 'You token was refreshed so repeat your last action and it will work!'. User doesnt know about tokens.

karagozidis
Автор

Okay, I watched another video on how to implement refresh tokens and the way they implemented it was... The user signs in and gets a refresh token and access token. Then when the access token expires and the user tries to access something protected they will use their refresh token to get a new access token AND a brand new refresh token. So basically any time a new access token is created a new refresh token is also created. Is this method more or less secure or the same?

cameronmorton
Автор

At what point would a user generally be signed out without the refresh token in place?

litepker