What are JSON Web Tokens? JWT Auth Explained [Tutorial]

What are JSON Web Tokens? JWT Auth Explained [Tutorial]

freeCodeCamp.org

4 года назад

123,674 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

GoodiFY
GoodiFY - 16.07.2023 01:48

I loved the tutoria ❤❤🎉l, but I'm having a little problem with my backend refresh_token api while using mongodb as the database and mongoose for querying the database, it doesn't seem to be working and I need help with that.

Ответить
CANMERTINYO
CANMERTINYO - 30.06.2023 21:46

thanks

Ответить
phmountaindog
phmountaindog - 27.12.2022 15:35

Pitty the camera was out of focus - but otherwise a good video

Ответить
Simardeep Singh Mudhar
Simardeep Singh Mudhar - 24.10.2022 14:08

God Level Stuff , Loved it

Ответить
André
André - 14.09.2022 00:42

Thanks for the tutorial. Appreciated.

Ответить
_xentropy
_xentropy - 12.08.2022 20:45

Thank you for making this so understandable.

Ответить
Naman Kothari
Naman Kothari - 06.06.2022 16:36

Can someone please explain me in simple words what did he say about versions w.r.t to refresh tokens?

Ответить
Gary P Weedman
Gary P Weedman - 17.05.2022 22:16

Excellent

Ответить
Indian blogger Parul vineet sharma
Indian blogger Parul vineet sharma - 19.11.2021 15:57

Awesome

Ответить
Pari Paria
Pari Paria - 20.10.2021 09:29

you are awesome man🌷🌷 thanks for sharing your knowledge😍🙏🏻

Ответить
Philcob Suzuki
Philcob Suzuki - 22.04.2021 06:11

How can I ever learn thing like JWT without videos like this? Reading docs doesn't help! Thank you so much!

Ответить
Growtoups
Growtoups - 23.03.2021 06:06

i dont want to hurt your feeling but im tired of indian accent there's too much

Ответить
__TM Mmanzi
__TM Mmanzi - 13.01.2021 18:45

Hello @freecodecamp
Thanks for ur interesting and best remarkable courses you provide
but during using the refresh token to create new accesstoken, on frontend for me once I refresh the it takes me back to the login page
just help me to solve that thanks best regards
Here is my endpoint for the refreshtoken

app.post("/refresh_token", async (req, res, next)=>{
const token = req.cookies.refreshToken;
//if there is no token
if(!token) return res.json({accessToken: ''});
//if we have token
let payload = null;
try {
payload = jwt.verify(token, process.env.REFRESH_TOKEN_SECRET);
} catch (error) {
return res.send({
accessToken: ""
})
}
//let's find the user
let user = await User.findById(payload.userId);
if(!user) return res.json({accessToken: ""});
if(user.refreshToken!==token) return res.send({accessToken: ""})
let accessToken = createAccessToken(user._id);
let refreshToken= createRefreshToken(user._id);
user.refreshToken = refreshToken;

sendRefreshToken(res, refreshToken);

return res.send({ accessToken });


})

Ответить
Ratna Chaitanya
Ratna Chaitanya - 17.11.2020 11:43

If iam logged in a website through auth redirect url token in one browser and again if iam logged in the same website in another browser, it creates another different url token for login . Then which url token will be registerd or tracked by that website ? either First one or next one..?? Thankyou for ur valuable answer in advance..!!

Ответить
Carlos Eduardo Pérez
Carlos Eduardo Pérez - 13.09.2020 23:05

What font are you using? It looks beautiful

Ответить
Victor Ukok
Victor Ukok - 21.07.2020 03:15

Thanks a lot for this freecodecamp.

Ответить