Django API Authentication using JWT Tokens

  Рет қаралды 173,249

Scalable Scripts

Scalable Scripts

Күн бұрын

👉 Check our website: scalablescripts.com
Python Django login and generate JWT Token using HttpOnly Cookies. We will Login using JWT( JSON Web Token ) which is the standard method for SPA Authentications. We will not use the traditional "Bearer method" but instead we will login using HttpOnly cookies which is a more secure authentication.
Source Code: github.com/scalablescripts/dj...
This video can be combined with other videos:
React and Django JWT Authentication: • React & Django JWT Aut...
VueJs and Django JWT Authentication: • VueJS & Django JWT Aut...
Angular and Django JWT Authentication: • Angular & Django JWT A...
NextJS and Django JWT Authentication: • NextJS & Django JWT Au...
NuxtJS and Django JWT Authentication: • NuxtJS and Django JWT ...
Svelte and Django JWT Authentication: • Svelte & Django JWT Au...
00:00 Preview
00:28 Django Rest Framework Setup
02:48 User Model
05:43 Database
08:47 Register
19:21 Login
30:22 Authenticated User
35:01 Logout
#python #django

Пікірлер: 199
@learningchannel4001
@learningchannel4001 2 жыл бұрын
The best token based Authentication I have watched. Very detailed. Thank you
@dawoodsiyam512
@dawoodsiyam512 11 ай бұрын
man you are the best, straight to the point, no copy pasting, and very easy and readable code and step by step process, something that lots of tutorials struggle with, thank you so much.
@abdirahmanabdullahi1966
@abdirahmanabdullahi1966 6 ай бұрын
Is loggingView working for you?
@jasonvilla3696
@jasonvilla3696 4 ай бұрын
Watching this today, although this is 3 years ago and there is an optimized way to use JWT, this really helped me understand what happens during a JWT authentication. Kudos
@MissoyKE
@MissoyKE 2 ай бұрын
share link for the optimized way
@shagilislam2533
@shagilislam2533 Ай бұрын
Truly the smoothest and most accurate Django-JWT Tutorial I've ever seen!!!
@raulemilianomirandagutierr3313
@raulemilianomirandagutierr3313 3 жыл бұрын
Man you don't know how much I appreciate this video, let me tell you I've been looking for something like this for weeks, let me tell you there's nothing.
@jaitungodhani2334
@jaitungodhani2334 2 жыл бұрын
plz tell me if you know how i applied Bearer method in video video instead of cookies.
@nicolasportelli3766
@nicolasportelli3766 Жыл бұрын
Very good video! Without getting lost in the bush, getting to the concept clearly Greetings from Argentina!
@EveryGameArchive
@EveryGameArchive Жыл бұрын
Thanks! I had hard times trying to discover how to use jwt and you solved all questions that i had.
@aryanagarwal2257
@aryanagarwal2257 2 жыл бұрын
Thank You! You have explained it so clearly, I haven't been able to understand this since days but with this one I was able to easily
@HEATER_APP
@HEATER_APP Жыл бұрын
super straightforward and concise, great job!
@zakariaazahaf394
@zakariaazahaf394 2 жыл бұрын
I dont usually comment on yt videos, but this video is so damn good, with your explanations and the way how you talk. Keep up brother
@konstantinoskostopoulos9794
@konstantinoskostopoulos9794 3 жыл бұрын
Thanks a lot man, I had a hard time until I saw this one. The explanations were on point as well, cors even fixed a front-end problem my team had. Hope you grow big!
@ScalableScripts
@ScalableScripts 3 жыл бұрын
Glad it helped!
@nepdevtech
@nepdevtech 3 жыл бұрын
@@ScalableScripts I am getting error while decoding the token in userview
@goodboy435
@goodboy435 2 жыл бұрын
@@nepdevtech me too... For me it says. " 'str' object has no attribute 'decode' " Have u got the solution??
@jayantpatankar5967
@jayantpatankar5967 2 жыл бұрын
@@ScalableScripts why I am getting - RecursionError: maximum recursion depth exceeded while calling a python object. How to solve...
@loganathant9840
@loganathant9840 Жыл бұрын
​@@goodboy435 decode is not needed since its already decoded remove the decode and it will work
@bilaltufaildev
@bilaltufaildev 4 ай бұрын
Perfect Tutorial for basic auth so far. Loved it! Keep it up Sir! 💖
@devniel
@devniel Жыл бұрын
Awesome! thanks for your explanation. I just want to remind these typical topics for django, it always important to continue improving our skills.
@gamingfundas
@gamingfundas 3 жыл бұрын
very well explained....loved this. Yeah, some exceptions are that, the person has to make a create_superuser function to create a superuser but its fine. JWT explained wonderfully
@allanalais7859
@allanalais7859 2 жыл бұрын
in serializer?
@thabosiphiwemngoma1859
@thabosiphiwemngoma1859 6 ай бұрын
This is an amazing video. So clear. Answered most of my questions before I asked them.
@abbaskareem5281
@abbaskareem5281 Жыл бұрын
This is the best video on JWT and tokens in django and django-rest-framework ... thank you million times sir ❤❤
@sorooshmoghimi5494
@sorooshmoghimi5494 Жыл бұрын
that was really helpful, and very straightforward! Thank you so much.
@sushovitshah9083
@sushovitshah9083 4 ай бұрын
Best video for drf authentication. Totally loved it and learned a lot.
@shadmanlatif6530
@shadmanlatif6530 2 жыл бұрын
Legit helped me
@ArghyaBhattacharyaNITA
@ArghyaBhattacharyaNITA 3 жыл бұрын
Thanks for the clear explanation. Bdw, what about the refresh token.. don't we need that as well ??
@manolismandamadiotis5853
@manolismandamadiotis5853 2 жыл бұрын
very helpful video and keeping it simple tthanks!
@roamandlift
@roamandlift 3 жыл бұрын
Such a dope explanation 🔥🔥🔥
@davidadu-tenkorang3186
@davidadu-tenkorang3186 3 жыл бұрын
Excellent work. Thank you
@rashedulhasanporosh7722
@rashedulhasanporosh7722 2 жыл бұрын
Thank you so much. It was a great help!
@pradyumnabharadwaja8237
@pradyumnabharadwaja8237 Жыл бұрын
The best explainantion and ONPOINT, loved it, Thank you 🙏
@maksymmalicki2720
@maksymmalicki2720 Жыл бұрын
Amazing tutorial, thank you very much!
@imcamilaaa
@imcamilaaa 3 жыл бұрын
thank you so much for the video, because of this now i and my group can sleep in peace hahahaha
@keshavachandu99
@keshavachandu99 2 ай бұрын
I learnt a lot here Thank You !!!
@johntygomes6519
@johntygomes6519 3 жыл бұрын
Very Greeat Explanation Sir...ThankYou
@marcellacarvalho6705
@marcellacarvalho6705 2 жыл бұрын
Thank you for this. You are awesome!
@shashishekhar----
@shashishekhar---- 9 ай бұрын
Great content, subscribed !
@jorgeperalta9780
@jorgeperalta9780 Ай бұрын
awesome video! Thank you!
@_nishadkv
@_nishadkv 2 жыл бұрын
Helps a lot.. Thanks buddy
@user-dev953
@user-dev953 Жыл бұрын
This was very helpful thank you
@user-en1km2zj5v
@user-en1km2zj5v 5 ай бұрын
thank you very much. excellent presentation of the material
@nguyenichthanhtu8502
@nguyenichthanhtu8502 Жыл бұрын
This is Awesome, helpful for me. Thanks
@NiM44
@NiM44 2 жыл бұрын
Very well explained , Thanks
@abcrectify6916
@abcrectify6916 2 жыл бұрын
Thanks for making this video.
@mrek1668
@mrek1668 Жыл бұрын
Great video! If I'm using Django templates instead of a separate front end, can I still use JWT for authentication?
@jakubrudy9372
@jakubrudy9372 3 жыл бұрын
thank you for this tutorial very much!
@yaroslavstetsko4174
@yaroslavstetsko4174 2 жыл бұрын
It is perfect tutorial, thank u, and continue.
@edwardzombie9222
@edwardzombie9222 Жыл бұрын
Спасибо большое за урок! Очень помог!
@k1vz_
@k1vz_ 29 күн бұрын
very nice, thank you!!
@nicklennonfortes9611
@nicklennonfortes9611 Жыл бұрын
best teacher ever
@Experts_top_5
@Experts_top_5 Жыл бұрын
Excellent man!! thanks a lot
@gregocanepa
@gregocanepa 3 жыл бұрын
Awesome tutorial dude! One question: at 21:08 when you are fetching the user from the db, why do you do a filter and then a first instead of simply a get()? Thanks!
@souravjha2146
@souravjha2146 2 жыл бұрын
filter(), whenever you expect more than just one object that matches your criteria. If no item was found matching your criteria, filter() returns am empty queryset without throwing an error. get(), you expect one (and only one) item that matches your criteria. Thus if there are more than one objects returned in queryset we would know that via filter
@luisematos_
@luisematos_ 2 жыл бұрын
I have to say THANK YOU!
@Travellife8877
@Travellife8877 3 жыл бұрын
just osm content and step by step explaination
@Acel-01
@Acel-01 2 жыл бұрын
GREAT Tutorial!
@hyunjungoh6672
@hyunjungoh6672 2 жыл бұрын
I love this video!!!!! the best ever!
@paasxx
@paasxx 11 ай бұрын
Superb content, very helpful
@frankydubi
@frankydubi 2 жыл бұрын
The biggest THANK YOU!
@PartimeMemer
@PartimeMemer 10 ай бұрын
Amazing tutorial dude
@aleksandrsemenov1764
@aleksandrsemenov1764 2 жыл бұрын
Great job, thanks!
@anarbairam
@anarbairam Жыл бұрын
great explanation!
@jadedanial3255
@jadedanial3255 Жыл бұрын
great tutorial! thumbs up!
@shubhamathawane02
@shubhamathawane02 4 ай бұрын
Can you tell how can i send token from frontend to backend again for each request as i am storing it as cookie on frontend ?
@juiceearthhh7225
@juiceearthhh7225 Ай бұрын
Thanks helped a lot
@adhy612000151
@adhy612000151 6 ай бұрын
Thanks a lot good man! God always bless you!
@adhy612000151
@adhy612000151 6 ай бұрын
Many Many Thanks For you good man!
@Craennie
@Craennie 5 ай бұрын
The cookies aren't saving automatically when I use ReactJs - Axios. How can I save the cookies automatically and also send it as part of the request using Axios or Fetch API
@mayankdandwani9951
@mayankdandwani9951 2 жыл бұрын
Superb Content Bro
@HarshitGupta-vo5bm
@HarshitGupta-vo5bm Жыл бұрын
is that pyjwt assigns refresh token to user , just like simple jwt does ? also does it refresh tokens automatically after expiration time ?
@achrafbilal4200
@achrafbilal4200 3 жыл бұрын
The best (from morocco)
@engrnasirshah4426
@engrnasirshah4426 2 жыл бұрын
Thanks very will explanation
@ivanromanov7120
@ivanromanov7120 8 ай бұрын
Thank you for video! Can you tell what is the soft you use for DataBase on 06:42 ?
@Nikhil-Tomar
@Nikhil-Tomar Жыл бұрын
What about CSRF policies and securities, Why are they not applied here?
@markgemesi6783
@markgemesi6783 Жыл бұрын
thanks, good video
@angwamoses5005
@angwamoses5005 2 жыл бұрын
Please, how can i use django default isAuthenticated permission instead of having to check if the token is in cookie.
@na_na_na6577
@na_na_na6577 Жыл бұрын
Thank you very much
@duberlyivanmondragonmancha6198
@duberlyivanmondragonmancha6198 10 ай бұрын
Good video!!
@estrum1647
@estrum1647 8 ай бұрын
amazing video
@muruganraja9
@muruganraja9 2 жыл бұрын
Excellent tutorial,
@understand1004
@understand1004 Жыл бұрын
26:10 dont need to .decode("utf-8") just token = jwt.encode(payload, 'secret', algorithm='HS256') that's it
@majmunovski
@majmunovski 3 жыл бұрын
Thank you very much!
@ScarxciaSkaix
@ScarxciaSkaix 2 жыл бұрын
Thank you so much!
@musicbrorijit
@musicbrorijit Жыл бұрын
Does this work for multiple users getting logged in and out at the same time?
@gautammishra96
@gautammishra96 3 жыл бұрын
Don't we have to invalidate the JWT before removing it?
@TommyBrick
@TommyBrick 3 жыл бұрын
Hi, great video! One question: At @26:12, why did you decode the token? I get the error "'str' object has no attribute 'decode'" If I drop the decoded I get a decoded string.
@matteob9342
@matteob9342 3 жыл бұрын
Hi, You can downgrade the PyJWT package to 1.7.1 or remove the call to decode. It should work
@TommyBrick
@TommyBrick 3 жыл бұрын
@@matteob9342 removed .decode() and it dit work fine afterwards. Thanks!
@goodboy435
@goodboy435 2 жыл бұрын
Got same error.. Just after an year.
@goodboy435
@goodboy435 2 жыл бұрын
@@matteob9342 thanks matteo... Ur removing decode() call method worked for me too...
@toufikbenkhelifa917
@toufikbenkhelifa917 2 жыл бұрын
@@goodboy435 how can i do it ?
@muskulanikhil3623
@muskulanikhil3623 2 жыл бұрын
you are a life save dude
@toufikbenkhelifa917
@toufikbenkhelifa917 2 жыл бұрын
can i ask u ?
@omarchristie3923
@omarchristie3923 2 ай бұрын
Hey, I did this auth and now connecting it to Vue js frontend but when I sign out, I am still able to access protected views that need authentications. Only when I clear the browser cookie do the access stop. Also the cookie is still within the header when I sign out. How can I fix this? it work fine in postman.
@achirasilva2567
@achirasilva2567 3 ай бұрын
There's a issue with "utcnow()" function in newer django versions. My cookie instantly get deleted.
@novoehuevoe9340
@novoehuevoe9340 2 жыл бұрын
Do you know how to use JWT auth in django's admin interface?
@mehboobshaikh8396
@mehboobshaikh8396 3 жыл бұрын
can you make a video on how to integrate Django rest framework with Keycloak?
@AshishSingh-dn8wb
@AshishSingh-dn8wb 3 жыл бұрын
Can we use this cookie based authentication with React Native?
@davidadu-tenkorang3186
@davidadu-tenkorang3186 3 жыл бұрын
Can PyJWT and Simple JWT be used for a django project? Also when the data from the frontend gets to the backend, django raises an error with the email. Thank you for your attention
@helissonoliveira3807
@helissonoliveira3807 2 жыл бұрын
Did you figured out way this happens?
@baldevvermamohapatra2146
@baldevvermamohapatra2146 Жыл бұрын
I'm getting type error when using a id of a foreign key of a model to reference the payload
@faridhabibli625
@faridhabibli625 2 жыл бұрын
Thanks a lot man
@allanalais7859
@allanalais7859 2 жыл бұрын
How can I create super users?
@jaitungodhani2334
@jaitungodhani2334 2 жыл бұрын
how i fetch token data same like you when i passing token in barrier token panel plz tell me if any ideas
@sergeysoloviov9802
@sergeysoloviov9802 3 жыл бұрын
if someone have login error with str.decode blahblah. it can be fixed with freezing PyJWT==1.7.1 in requirements.txt
@faysalahmed3601
@faysalahmed3601 2 жыл бұрын
'User' object has no attribute '_default_manager' getting this error at 15:21 minutes. Can anybody suggest me some solutions?
@assaqofi
@assaqofi 2 жыл бұрын
thank alot this is what i am looking for, but how to update the user data ?
@joventan4303
@joventan4303 2 жыл бұрын
Thank you! :)
@jaitungodhani2334
@jaitungodhani2334 2 жыл бұрын
how i perform traditional Bearer method for above code plz tell me if you know
@nikhilaryal5589
@nikhilaryal5589 Жыл бұрын
Thanks man!!
@JohnBiddulph
@JohnBiddulph 5 ай бұрын
29:08, I have installed django-cors-headers and added to settings app and middleware, I am getting: No module named 'corsheaders' please help
@kevinbeano1916
@kevinbeano1916 2 жыл бұрын
great tutorial. How about the guard ?
@user-ed9yw3nz4s
@user-ed9yw3nz4s 3 жыл бұрын
thanks for high quality video, but i have a question for you~~ in the Userview part,, why you attech code -> ".first()" ?? when I want all of the logined people, how can i???
@ScalableScripts
@ScalableScripts 3 жыл бұрын
Because filter() returns a List and I add .first() to retrieve a single object. To get all the logged in users you have to store the jwt with the user_id in a database
@user-ed9yw3nz4s
@user-ed9yw3nz4s 3 жыл бұрын
@@ScalableScripts explain code??TT
@blabla-kk8bl
@blabla-kk8bl 3 жыл бұрын
Is it refreshing jwt token automatically after expiry?
@RiderGopal0102
@RiderGopal0102 2 жыл бұрын
Tysm. Plz login using role such admin, user,student,teacher..plz make video on this
What Is JWT and Why Should You Use JWT
14:53
Web Dev Simplified
Рет қаралды 1,1 МЛН
ТАМАЕВ УНИЧТОЖИЛ CLS ВЕНГАЛБИ! Конфликт с Ахмедом?!
25:37
THEY made a RAINBOW M&M 🤩😳 LeoNata family #shorts
00:49
LeoNata Family
Рет қаралды 41 МЛН
One moment can change your life ✨🔄
00:32
A4
Рет қаралды 30 МЛН
GPT4o Mini - Lightning Fast, Dirty Cheap, Insane Quality (Tested)
13:20
How To Make a Django REST API - Full Tutorial & Deployment
40:18
Tech With Tim
Рет қаралды 64 М.
Angular JWT Authentication
33:50
Scalable Scripts
Рет қаралды 71 М.
Django REST Framework - Build an API from Scratch
40:39
Caleb Curry
Рет қаралды 208 М.
Django REST JWT authentication |  Simple JWT
14:41
Code Aura
Рет қаралды 35 М.
Difference between cookies, session and tokens
11:53
Valentin Despa
Рет қаралды 603 М.
ТАМАЕВ УНИЧТОЖИЛ CLS ВЕНГАЛБИ! Конфликт с Ахмедом?!
25:37