React Automatically Refresh Tokens

preview_player
Показать описание
Learn how to automatically refresh your jwt tokens in React. Using afterware, we will check the response from the server every time we make a request and if the server gives us a new token we will save it to localStorage.

Starter code:

----
Video Suggestions:

----
Follow Me Online Here:

----
#benawad

----
#benawad
Рекомендации по теме
Комментарии
Автор

Your refresh token should ideally not be put in localstorage due to JS can reach it there. It should rather be placed in a secure http only cookie.

SavilliMillard
Автор

You should NOT store refresh tokens in the browser, it is very insecure since they usually last much longer than secret keys, and it if is compromised it can be used to generate other secret tokens.

arielfuggini
Автор

Very nice Ben! Thanks! Can you show us how to add email confirmation into your auth logic flow?

TelosMediaOrgOfficial
Автор

worked like a charm, but every time the token changes i have to reload the page for the queries of the user to be authenticated and show me the correct information :D

Romucci
Автор

Awesome video, thank you. Would this technique for refreshing tokens work with React Native as well?

kenwfrederick
Автор

Thanks so much for this video. I'm experiencing unexpected behavior following along with this implementation, I find that I have to log in after a week in spite of using the site every day. I'm able to confirm that I am receiving and saving updated refresh tokens when the site sends a request to the server. Any suggestions on how to troubleshoot?

kenwfrederick
Автор

Hi Ben. If I am using Apollo 2 this code is deprecated, because createNetworkInterface isn't exist in this new version. Do you know how migrate this code?

theKaminoanru
Автор

this is cool, but how would you do a logout with react

jasonshen
Автор

am i the only one who has NO fucking idea wtf is going on???

evanceltic