No video

Django Rest Framework Series - JWT Token Authentication with React - Part-3

  Рет қаралды 123,605

Very Academy

Very Academy

Күн бұрын

Пікірлер: 311
@harunozkok7888
@harunozkok7888 3 жыл бұрын
I dont know why this content doesnt have so much visualization.. This is the best content that i have seen related to setup of Django rest with react js.. I have paid a course for this.. explanations were much worse.. i didnt understand anything related to custom user models and tokens.. Too much respect for this guy
@veryacademy
@veryacademy 3 жыл бұрын
Thank you!
@alpstinger5083
@alpstinger5083 3 жыл бұрын
Couldn't agree more.
@VskiDevs
@VskiDevs 2 жыл бұрын
agreeeeeed💯 its 2022 and this is the best react-django tut for sure
@agroforestryconsultancyroz3157
@agroforestryconsultancyroz3157 2 жыл бұрын
It feels like this channel provides tutorials from the teacher with the highest programming skills I've seen so far.
@sergeipoliakov1845
@sergeipoliakov1845 2 жыл бұрын
For anyone using react-router-dom version 6 or newer, 'useHistory()' was deprecated and replaced by 'useNavigate()'. Also was deprecated and replaced with
@veryacademy
@veryacademy 2 жыл бұрын
Thank you - I will have an update for this series over the next few months no doubt.
@iaggocapitanio7909
@iaggocapitanio7909 2 жыл бұрын
or just type: yarn add react-router-dom@5.2.0 to ad an old version
@jiweihe3413
@jiweihe3413 Жыл бұрын
thanks, no wonder I have not seen these hooks before.
@burburchacha
@burburchacha Жыл бұрын
thanks so much for posting this!
@wolfisraging
@wolfisraging 4 ай бұрын
This is just a brilliant video. I mean the efforts you've put in, mad respect mate!
@prvizpirizaditweb2324
@prvizpirizaditweb2324 2 жыл бұрын
The way you firstly explain why we need it and how does it work, with diagrams is really helpful, thank you very much
@veryacademy
@veryacademy 2 жыл бұрын
Glad it was helpful! Looking at your other comments I can see you are someone who likes details
@animeshkumar1201
@animeshkumar1201 3 жыл бұрын
Best tutorial on token authentication using django JWT and react. I liked the content very much. Your channel should become famous.
@veryacademy
@veryacademy 3 жыл бұрын
Thank you so much 😀
@gunnar6922
@gunnar6922 3 жыл бұрын
You are a brilliant teacher! Thank you so much! After hours of frustration when trying to understand JWT i stumbled upon your playlist and i now do not feel dumb and lost. It's pure join to understand this stuff och get things to work as expected.
@veryacademy
@veryacademy 3 жыл бұрын
Thanks Gunnar, its really simple I hope you would agree once you get things up and running.👍
@GaneshPatil-fs6cn
@GaneshPatil-fs6cn 3 жыл бұрын
We don't get such content even after paying. Hats off !!! Thank you for the great content !!
@veryacademy
@veryacademy 3 жыл бұрын
It's my pleasure
@alpstinger5083
@alpstinger5083 3 жыл бұрын
Love the "hello and welcome back". Another awesome tutorial.
@veryacademy
@veryacademy 3 жыл бұрын
Hello there! 😂
@timothyclarke16
@timothyclarke16 2 жыл бұрын
Thank you so much for this tutorial! I was in a tailspin of whether to use Django's built-in token authentication or other 3rd party packages, which seemed like a pain to integrate into my project and had very little return of investment. This seems like it's by far the best way to go.
@TheBodybuildingG
@TheBodybuildingG 3 жыл бұрын
Issues with this : - the permissions are set to AllowAny so the login/logout does not affect the accessibility of the data from the server. An example where the posts cannot be seen only when logged in would been better. - the logout component keeps creating blacklist token even after the user is logged out . keep pressing the logout button and the blacklist tab in the admin page will fill up - again the last part of the series is rushed. Maybe in the future u can split this tutorials for better experience. (we obviously get tired by the end) Still I appreciate the hard work u put in to make this videos with topics that are not touched by the general youtubers in this field..
@veryacademy
@veryacademy 3 жыл бұрын
Thanks George, appreciate the time you spent giving very constructive feedback. I take it all on-board, I am still developing better methods to present information in these longer tutorials. 👍
@SonySupporter
@SonySupporter 2 жыл бұрын
Yep, the blacklist table is filled with tokens without user.
@jsr7599
@jsr7599 2 жыл бұрын
Is there a resource that is complete for JWT for react/django? Or could you kindly document the steps needed to do so?
@ummehanyarozshandaanny2846
@ummehanyarozshandaanny2846 2 жыл бұрын
How can someone give such great work for free!!! It's the best tutorial to me till now for Django... I wish I could do more than subscription and like. Thanks a lot...
@osamakhan5397
@osamakhan5397 3 жыл бұрын
the way you explained such a complex topic... sir ji you are great
@Thatguy-rh5ls
@Thatguy-rh5ls 3 жыл бұрын
Your channel is a lifesaver 😭😭😭❤️❤️❤️
@andogrando487
@andogrando487 3 жыл бұрын
Agreed with everyone this is the most succinct and understandable walkthrough of Django and DRF - thank you so much you deserve so many more views!
@indojojon892
@indojojon892 3 жыл бұрын
I have a question. How does the frontend recognize if the user is logged in or not?
@gopalmatcha4436
@gopalmatcha4436 Жыл бұрын
Hands down one of the best tutorials I've ever seen! Thank you good sir!
@brom18711
@brom18711 3 жыл бұрын
My progression over the past three months has been FCC (HTML, CSS, JS, React), Dr Chuck (Python 4 everyone), Corey Schafer (Flask/Django), then building my own Flask/Django projects. It was then that I didn't know what to do next, until I discovered this!
@veryacademy
@veryacademy 3 жыл бұрын
Hi Beale. Promise you this, you will never run out of something next to do. Welcome to development. 👍
@indojojon892
@indojojon892 3 жыл бұрын
I have a question. How does the frontend recognize if the user is logged in or not?
@DevBishwasBh
@DevBishwasBh 2 жыл бұрын
Thanks but please do NextAuth with Django Rest Framework, with Google OAuth. Also, adding "email and password" based authentication on the same tutorial will be great. I am desperetely waiting for your response.
@veryacademy
@veryacademy 2 жыл бұрын
Hey, I see you are desperately waiting for my response! Sounds like a good tutorial, I will put it on my list, thank you!
@DevBishwasBh
@DevBishwasBh 2 жыл бұрын
@@veryacademy Thanks a lot. You gave me internal peace. I searched a lot on the web about the NextAuth and DRF-based authentication but got very few really old articles. I am really waiting for your video.
@DevBishwasBh
@DevBishwasBh 2 жыл бұрын
Also, please remember the Google OAuth Part, that's the most essential for me right now. Thanks again.
@DevBishwasBh
@DevBishwasBh 2 жыл бұрын
@@veryacademy Is the video uploaded?
@elmanpathan4872
@elmanpathan4872 3 жыл бұрын
Thank you so much, very few people can explain in such a simple and concise manner.
@AibekToroev
@AibekToroev 2 жыл бұрын
Your explanations are very very very detailed and it is good for understanding how things actually work behind the scenes. Thank you so much!
@Pmarmagne
@Pmarmagne 2 жыл бұрын
Thank you so much for posting that video. Liked, saved and subscribed! I'm starting to learn react and I use Django as the backend. This is just what I needed!
@veryacademy
@veryacademy 2 жыл бұрын
Glad it helped!
@PraisPranav
@PraisPranav 3 жыл бұрын
You explain everything very beautifully. Now node js is in trend.. but I think django is simple
@veryacademy
@veryacademy 3 жыл бұрын
Hi Agni, yeah, I have come to the party late that is for sure with Django. Thank you for the support. 👍
@successhycenth
@successhycenth 2 жыл бұрын
Best teacher online....
@josephc3080
@josephc3080 3 жыл бұрын
Stellar tutorial! This has really helped me get past a big sticking point in my own full stack app.
@veryacademy
@veryacademy 3 жыл бұрын
Great to hear!
@ahmedshahriarsakib5728
@ahmedshahriarsakib5728 3 жыл бұрын
This is exactly what I was looking for
@veryacademy
@veryacademy 3 жыл бұрын
👍
@ahmedshahriarsakib5728
@ahmedshahriarsakib5728 3 жыл бұрын
@@veryacademy One question, If I don't integrate other APIs (ex - google, FB sign in/up) then I don't need to implement OAuth at all right? I can only rely on JWT for authentication and authorization both
@Luffy-hi6xw
@Luffy-hi6xw 4 жыл бұрын
Wow :d ... a Lot of topics have been covered since i left... Actually i was sick ..but im fine now so wil continue watching from where i left
@veryacademy
@veryacademy 4 жыл бұрын
Welcome back, sorry to hear you were ill, hope you are better now! 👍
@azrmuradl6420
@azrmuradl6420 2 жыл бұрын
Shout out to you for creating such a great content! Keep it up man!
@paborlouise319
@paborlouise319 4 жыл бұрын
Wow.... You're taking this to a greater level.
@veryacademy
@veryacademy 4 жыл бұрын
Thank Pabor, things are slowly moving forward, any questions as per normal just please ask. Always happy to take feedback on how I can best deliver content for you
@paborlouise319
@paborlouise319 4 жыл бұрын
@@veryacademy that's what about you sir. Good work.
@media7588
@media7588 Жыл бұрын
So thank you
@gabrielmota3583
@gabrielmota3583 3 жыл бұрын
Wow, this is very high quality content! Subscribed! I would find also interesting to learn how implement something like useContext, to keep the user info available through components, along with this React and Django/JWT configuration!
@aashayamballi
@aashayamballi 4 жыл бұрын
1K Subs!! Congratulations 🎉🎉🎉
@veryacademy
@veryacademy 4 жыл бұрын
Thank you ☺️
@darshmamtora2863
@darshmamtora2863 3 жыл бұрын
Video is great, just pointing out that refresh URL in axios.js file, it returns only access token but in code refresh is also stored again as undefined, so simply remove the refresh token line else it will give error
@samthompson5138
@samthompson5138 3 жыл бұрын
I think I am experiencing this error. Which line exactly needs to be removed?
@EUU100
@EUU100 2 жыл бұрын
@@samthompson5138 did you end up finding out?
@benukapunchihewa4125
@benukapunchihewa4125 3 жыл бұрын
Thank you very much! Top level content. You're a life saver mate.
@ram0973
@ram0973 2 жыл бұрын
Thank you very much, gonna use this with Spring Rest Api, made some changes with React 18 and TypeScript
@felixfigueroa
@felixfigueroa 3 жыл бұрын
Master of Masters 🙇‍♂️
@veryacademy
@veryacademy 3 жыл бұрын
👍
@anjaladhikari8951
@anjaladhikari8951 10 ай бұрын
If anyone faced problem during blacklisting it's probably because no response was sent from the blacklisting view in the try part. So make sure you include a Response("Sucessful", status=status.HTTP_200_OK) inside the try
@FreeDomSy-nk9ue
@FreeDomSy-nk9ue 2 жыл бұрын
I think you mistakenly named the function SignUp 1:24:00 This was very useful, thank you
@ssentumbweenoch3430
@ssentumbweenoch3430 2 жыл бұрын
Great tutorial, can you also make a tutorial to explain how to properly use axios. It is not easy to understand interceptors. Overall, the tutorial is great, got me glued till the end.
@akashparit9418
@akashparit9418 3 жыл бұрын
best content on DRF on entire YT
@shawnbeans7389
@shawnbeans7389 3 жыл бұрын
hey, I'm trying to log in with a user and it says "No active account found with the given credentials" but when I try to login with superuser it's working fine. cannot log in with a normal user edt:fixed it
@indojojon892
@indojojon892 3 жыл бұрын
I have a question. How does the frontend recognize if the user is logged in or not?
@shawnbeans7389
@shawnbeans7389 3 жыл бұрын
@Joaquin Polonuer sorry bro i dont remember, I seeing this reply after 1 month
@shawnbeans7389
@shawnbeans7389 3 жыл бұрын
@@indojojon892 json web token
@vainav5794
@vainav5794 2 жыл бұрын
@Joaquin Polonuer i think this problem will happen id you dont hash the password before saving try to hash it then the jwt will work
@virajagharkar941
@virajagharkar941 2 жыл бұрын
@@vainav5794 do you have that solution
@johnanthony6612
@johnanthony6612 2 жыл бұрын
But where does the users information come from why does no one show this? Once you get the token how do you get and use the information from the logged in user with the token??
@veryacademy
@veryacademy 2 жыл бұрын
Hi John, appreciate this is a little abstract. Maybe not help you but for anyone else, I will refocus on this topic soon and break everything down further. It is always interesting to know about content you can't find and am happy to support this when I can. If you can articulate what it is you need or think more tutorials would be beneficial, please just let me know.
@dennisasamoah2213
@dennisasamoah2213 2 жыл бұрын
great stuff
@SonySupporter
@SonySupporter 2 жыл бұрын
When I refresh the page and the token is expired it goes into infinite loop.
@abhinavjha9231
@abhinavjha9231 3 жыл бұрын
thanks bro.. Love From India
@veryacademy
@veryacademy 3 жыл бұрын
👍
@Martt6
@Martt6 3 жыл бұрын
Great tutorial, thanks
@veryacademy
@veryacademy 3 жыл бұрын
Thank you!
@tommyeagen3763
@tommyeagen3763 3 жыл бұрын
wow such a wonderful viseriez
@dennisdigiacinto4758
@dennisdigiacinto4758 2 жыл бұрын
Hello, thanks for this series, it's really helpful! I was wondering if you also made a video on how to show/hide login/logout button based on logged in state. I've seen other people in the comments asking for the same thing and you said you would have made a video about it eventually, I tried to look for it in your channel but I did not find it.
@bipinon
@bipinon 3 жыл бұрын
you are just awesome 🍀
@sergeysergey6682
@sergeysergey6682 3 жыл бұрын
Just like I said before this content is next level! even comparing it to paid ones! Whats the advantage of using DRF with React instead of nodejs with React and how often DRF + React is used in production? thanks again ! Your efforts are greatly appreciated and your chanell will blow up in no time !
@veryacademy
@veryacademy 3 жыл бұрын
The best place to look for info like that is insights.stackoverflow.com/survey/2020 - really interesting. It is a good question - I think ultimately you are deciding between JS in the whole stack or Django - which works with Python applications. Much will depend on the type of project you are running, thinking long term and the tech you want to use or bolt on. Thank you for your nice comments - most appreciated and I thank you for taking your time to watch them. 👍
@orkhanrustamli2039
@orkhanrustamli2039 3 жыл бұрын
Hello Sergey. I am also quite new to development world (only 9 months) but I would like to answer your question based on what I got on internet for the same question. In short, Django is great and almost perfect but it is not very light in comparison to Flask or Node. Django is first choice when talking about short term for project or in other terms developing quickly. It solves a lot of problem by default for which you would spend weeks to complete in other frameworks. It has a lot of by default security features and so on. In contrast, Node or Flask which are lighter frameworks rather than Django are perfect choice for microservices environment. In microservice environment, the application`s parts are separated by teams and each team is working on their own part and at then end different parts are talking with each other using API. Imagine using Django for each microservice and at the result the whole project`s volume will be huge. I am sure Zander will correct my mistakes. Moreover, I saw some poeple proposing that Python is slower than some other languages and that can also be a reason to prefer them over Django.
@dawid_dahl
@dawid_dahl 3 жыл бұрын
Thank you so much!
@veryacademy
@veryacademy 3 жыл бұрын
Glad it helped!
@mariamzayed91
@mariamzayed91 2 жыл бұрын
thank youuuuu❤❤❤❤
@ahmedelmawrdy4381
@ahmedelmawrdy4381 3 жыл бұрын
keep it up bro!
@dheerajreddykondakindi7689
@dheerajreddykondakindi7689 3 жыл бұрын
How to display the error if username or email already exist we are only receving 400 bad request
@ankitdawadi7932
@ankitdawadi7932 3 жыл бұрын
I have tried many ways to solve it like installing django cors header, cors_allowed_origin and all. The thing perfectly work for registering and I can register my user. But it shows cors error while showing blog data and login. What may be causing it?
@TheWytzepakito
@TheWytzepakito 3 жыл бұрын
I had the same error, I mispelled Authorization in one of the components. Also I added: CORS_ALLOW_HEADERS = ( 'Accept', 'Accept-encoding', 'Authorization', 'Content-type', 'Dnt', 'Origin', 'User-agent', 'X-csrftoken', 'X-requested-with', ) to the django settings
@mohsenazadmanesh2245
@mohsenazadmanesh2245 11 ай бұрын
very good🤏🤏
@parthokr
@parthokr 2 жыл бұрын
Best channel for django stuff. Do you have any udemy course?
@undergroundindy
@undergroundindy 3 жыл бұрын
Great tutorial! You mentioned using a custom user model in favor of the tutorial moving along a bit quicker. How does creating a custom model make this faster over using the built in user model? What would I need to do differently if using the basic user model? Thanks! :D
@BenniK88
@BenniK88 3 жыл бұрын
Thanks for sharing so much insider knowledge. What I don't understand is why you use JWT instead of the build-in ´'rest_framework.authentication.TokenAuthentication'`? I currently work with the build-in Token Authentification. What are the reasons to switch? Should I?
@ikazuchi-san5772
@ikazuchi-san5772 3 жыл бұрын
jwt allows for stateless authentication and stuff, which removes the need for the server to verify your credentials on the database after the login, reducing its workload and stuff and its pretty safe if you know how to implement cuz the jwt is signed so if anyone comes and alters it the server will know t hat it has been altered without even checking the database it can also get your user data without having to go to the database for most of the stuff, it just reads it directy from the jwt
@aashayamballi
@aashayamballi 4 жыл бұрын
Thank you 👍🏽👍🏽
@veryacademy
@veryacademy 4 жыл бұрын
No problem 👍
@flashdaniel2796
@flashdaniel2796 3 жыл бұрын
You are a brilliant teacher! I love your work sir But I have a problem getting the current user that is log in using JWT in reactjs.
@veryacademy
@veryacademy 3 жыл бұрын
Have a look in the JWT token you probably have a user ID stored. You can extract that and use it to query the database to return the users info
@flashdaniel2796
@flashdaniel2796 3 жыл бұрын
@@veryacademy Yes I know sir I have already figured it out. Thank you for the quick reply sir I’m very much great full
@darosaleh830
@darosaleh830 2 жыл бұрын
@@flashdaniel2796 hi i am still having this problem do you know a fix? I cannot get the current user
@theCataras
@theCataras 3 жыл бұрын
Thank you for the video. Everything works so far - although i definitely need to work on some feedback for the user with all the form data ; I am a bit confused though: What are the next steps after this? The user can log in and log out but how can i actually display data specific to individual users or wether or not someone is logged in? Do you have any references to your own videos or keywords i can search for when it comes to best practices for handling user specific data (user id etc.)?
@veryacademy
@veryacademy 3 жыл бұрын
Hey Paolo, I will cover this in my next Quiz api tutorial👍
@theCataras
@theCataras 3 жыл бұрын
@@veryacademy Awesome! Thank you. I noticed when using the jwt django automatically assigns a user to the request. I assume that is managed by the authentication within django. I think it becomes very difficult for a beginner to keep track of all the best practices. When i search for some key ideas there always seem to be 5 different solutions for it. I wonder if you have any ressources for best practices? This even goes as far as structuring a project. Guess it's too much work to put all of this in one big series!?
@GinesLA
@GinesLA 10 ай бұрын
It saves 2 tokens for me on the blacklist, only 1 for you. In my case, one saves it when I log in and the other when I log out.
@giorgiomassignani8765
@giorgiomassignani8765 3 жыл бұрын
Hello Zander, Thank you for the wonderful state-of-the-art tutorials. I am following this one and everything works fine so far. The only thing is that I would like to implement a function (in the frontend) that checks if the user is logged in and if they are, it should change the header buttons Register and Login to the username and a "Logout button" that calls the logout function. How can I do that? I have been looking around a lot but I wasn't able to find anything helpful. Thanks.
@veryacademy
@veryacademy 3 жыл бұрын
Hi Giorgio - sorry to summarise my answer - this is a common question that I will address in the next tutorial of the new Quiz API series 👍 Thank you for the kind support.
@giorgiomassignani8765
@giorgiomassignani8765 3 жыл бұрын
@@veryacademy I understand it is a question that requires a pretty long answer. I can't wait wait for the new tutorial. Thank you again!
@Freecashnow2023
@Freecashnow2023 3 жыл бұрын
how safe is using localStorage with the access tokens?
@veryacademy
@veryacademy 3 жыл бұрын
As safe as you make it. But lets be honest - nothing is really 100%. Sorry I know this isn't the answer you are looking for. You will no doubt read some say it is an ok way to work, some will influence you not to use this. There just needs to be a deeper knowledge of big picture and understand the best practices when working with localStorage. Just keep reading 👍
@Troglodyte2021
@Troglodyte2021 2 жыл бұрын
Hi Zander Your tutorial is as good as always. Salute first! I have a question (or request) : How can I make login and logout link in the navbar show based on login status( or localStorage null or not)? I have been trying but to no avail. The navbar doesn't render unless being refreshed after login and logout.
@veryacademy
@veryacademy 2 жыл бұрын
Hi, without actually showing you. Just try and break it down. If you are using localstorage, first work out how to access the data. Check that it is changing when you log in/out and so on.
@Troglodyte2021
@Troglodyte2021 2 жыл бұрын
@@veryacademy I have checked another toturial and it just added windows.location.reload() after login or logout code. I was still wondering if I could do it without reload the page (kind of obsessed with this SPA thing). Or the bigger question is "Is it reasonable to have the navbar component to watch if my localStorage is null or not all the time?" Maybe reload is the correct way. The navbar should checks localStorage only when a user clicks login button or logout button. Would love to hear your take on this.
@shn8822
@shn8822 2 жыл бұрын
@@Troglodyte2021 Hi 👋, I have the same problem and I used reload , but this way is not good for React, I hope you fixed this problem because I tried all solutions but it did not work for me
@shn8822
@shn8822 2 жыл бұрын
This means that you changed all the code related to login or just added context? and is there a specific video you recommend I watch? Thank you so much for your response.
@Troglodyte2021
@Troglodyte2021 2 жыл бұрын
@@shn8822 I forgot how to implement it. But I think I had watched the net ninjia's React Context and Hooks Tutorial series for the knowledge.
@HolliVids
@HolliVids 2 жыл бұрын
Thanks for the excellent tutorial. Do you happen to have any resources for accomplishing the token refresh with a fetch wrapper instead of axios?
@AKshot60
@AKshot60 3 жыл бұрын
Hi very academy, can you make a tutorial on registering users through phone numbers? aka Twilio
@veryacademy
@veryacademy 3 жыл бұрын
Noted it - cant promise when you will see it.
@akashparit9418
@akashparit9418 3 жыл бұрын
can you please put the link to the resource from where you get the code of the interceptors
@KKLdynasty
@KKLdynasty 2 ай бұрын
who is here in 2024
@theophylline2423
@theophylline2423 3 жыл бұрын
Thanks for the great tutorial. I have a question about the security of refresh tokens: can the refresh token be copy/pasted and given to someone else, which allows them to get access tokens?
@veryacademy
@veryacademy 3 жыл бұрын
yes exactly that - if someone else gets the token they can gain access. This is why you might choose to rotate them often and protect them using HTTPS for example
@theophylline2423
@theophylline2423 3 жыл бұрын
@@veryacademy sorry for another question: do you still have the link/resource that explains the axiosInstance interceptors? Not sure I understood that part.
@robokopi00
@robokopi00 2 жыл бұрын
How do you test the /logout/ endpoint in Postman? Having a hard time trouble figuring it out...
@mimseridge
@mimseridge 3 жыл бұрын
Is it possible to send the jwt refresh token as an http-only cookie? That would improve security and avoid the need to store it in localStorage
@veryacademy
@veryacademy 3 жыл бұрын
Hi Kieran, yes - this is something that was requested a while back that I haven't delivered on yet. 👍
@joaoarthurbandeira
@joaoarthurbandeira Жыл бұрын
@@veryacademy Hey! How could I do that? Did u manage to put a video showing this? Is it really safer? Thanks!
@renzoblack5944
@renzoblack5944 Жыл бұрын
Hello. I can't seem to install axios. it keeps giving me errors.
@nahasco
@nahasco 2 жыл бұрын
May I ask would you prefer this over django rest auth?
@Sasuke-px5km
@Sasuke-px5km 11 ай бұрын
Hello is this still usefull for today? using nuxt 3?
@rayganmudberry375
@rayganmudberry375 4 жыл бұрын
awesome.
@veryacademy
@veryacademy 4 жыл бұрын
Thank you Raygan
@PhillippApetenok
@PhillippApetenok Жыл бұрын
In the create.js file saying that by default the author of the video is the author with id 1. How can I make that if I signed with id 2, the author field is going touse the id 2?
@PatrykJagielski
@PatrykJagielski 2 жыл бұрын
keeping token in local storage isn't safe due to XSS attack. But is it the better way there?
@aryanpandey2965
@aryanpandey2965 3 жыл бұрын
I am getting "TypeError: posts.map is not a function" error in react posts.js at the line "{posts.map((post) => {" , what should I do?
@veryacademy
@veryacademy 3 жыл бұрын
You have a syntax error I would imagine, just check the code repository and look at the syntax () and {} make sure you are using correctly...difficult to say with the code you provided
@aryanpandey2965
@aryanpandey2965 3 жыл бұрын
​@@veryacademy ok but one thing this error only occurs when i change PostList View permission from "IsAuthenticatedOrReadOnly" to any other permission. If I dont change the said permission, the error doesnt show up. But then even after logging out, the tokens don't get blacklisted and the same post still shows up even when the user is logged out.
@veryacademy
@veryacademy 3 жыл бұрын
@@aryanpandey2965 Ok, just follow the permissions - it might start in the settings.py file - you might have defined a permission there - next the view permission. Thats pretty much the two places where you probably have permissions. Now you just need to work out if you have assigned permissions to the user. That should get you nearer to the answer
@flaminiamazzitelli6017
@flaminiamazzitelli6017 3 жыл бұрын
@@veryacademy I think people are having these issue (me included) because at the point in which you complete the login feature, you might have already changed the App.js file to point to axios.js. If you follow along the video exactly as it is, the App.js will still have the old fetch code which doesn't contain the JWT headers hence why we get the Unauthorized errors. I just found out and I thought I'd share it. Btw - this video series is AMAZING - thank you so much!
@aperson9991
@aperson9991 2 жыл бұрын
I think that error handling with alert could be vulnerable to XSS attack
@createlifejr
@createlifejr 3 жыл бұрын
I have one doubt again. Sorry for the trouble.. How can we change the states of button with use state for login button and logout button..like to render with 2 different conditions..so when a user login..he shouldn't be able to see login button or register like it does now.. Thanks 😊
@veryacademy
@veryacademy 3 жыл бұрын
Hey Creately - I was going to make a video on state management - that is why I haven't done that yet. I was contemplating what approach to take - localstore - Redux / Hooks. But - yes the next part of this series - you will see this 100% - there is a few bits I want to tidy up - trying to keep the code and interface clean but not over complicate the code making it as easily readable as possible - please your questions are never any trouble - you have only ever been really helpful asking your questions - if I don't know what you are thinking / if I dont know what you need - I cant make tutorials to support you and no doubt others with similar questions. You are doing me the favour - so thank you and sorry to trouble you!
@createlifejr
@createlifejr 3 жыл бұрын
@@veryacademy Thank you and looking forward to it.
@siddharthshukla3557
@siddharthshukla3557 3 жыл бұрын
something like this: const [isLoggedIn, setIsLoggedIn] = useState(False) (isLoggedIn ? : )
@jhonyalberto4814
@jhonyalberto4814 2 жыл бұрын
Hi, thanks for your tutorial. I have been struggling to config a custom user model. I have configured the model and I have referenced it on the settings and it always leads me to the following error - "AttributeError: Manager isn't available; 'auth.User' has been swapped". Can anyone help please.....
@heroe1486
@heroe1486 3 жыл бұрын
Wanted to point out that if by any chance the refresh token in the localStorage is edited and doesn't match anything your code end up in an infinite loop calling "/api/token/refresh/" indefinitely. I modified it to check if it's in the Blacklist + using the /token/verify endpoint but even like this if you change its last character and it's not caught up by /token/verify/ you end up in a loop. The problem is that if the token isn't blacklisted you can't really tell if it's a fake one or not because OutstandingToken object isn't created when the pair is generated from /api/token/refresh but when you actually use the refresh token to ask for a new pair ( and it Blacklist it in the same time, kinda weird, why having these 2 models if it creates it and blacklist it directly ? The only time the outstanding token is created directly is at login when you manually provide credentials ). Because of that you can't ask the database if this token exist and you may end up in a loop if the fake one isn't detected by /api/token/verify/. If someone have a hint that'd be cool.. Edit : Finally creating another axios instance like AxiosSafeInstance without authorization headers and using it when you call /api/token/refresh does the job ( be sure to update the original Axiosinstance Authorization headers with tokens and not this one ).
@EUU100
@EUU100 2 жыл бұрын
hey i am very new to this, what topic should i research to learn about what you are talking about it seems important. Thanks for your time and your comment, best wishes
@saharhoshia9418
@saharhoshia9418 2 жыл бұрын
Do you have a code example?
@harshitgangwar2162
@harshitgangwar2162 3 жыл бұрын
In the line .post('token/refresh/', { refresh: refreshToken }) .then((response) => { the response.data only contains access_token and no refresh_token, but we are updating the refresh_token localStorage.setItem('refresh_token', response.data.refresh); this sets 'refresh_token' = undefined and next time when the request is made 'refresh_token' is found to be undefined and atob can be executed on undefined and gives error I think this may be the reason
@ed7590
@ed7590 2 жыл бұрын
After logging in how could I display the current username in the header on every page? Is it available from the token in local storage?
@virajagharkar941
@virajagharkar941 2 жыл бұрын
In this tutorial I'm Stuck at one place where I'm sending correct data and user info is present still I'm not able to login that user showing : "detail": "No active account found with the given credentials" .In Django Admin panel I'm able to see that users data
@ironheadmedia1625
@ironheadmedia1625 3 жыл бұрын
Hi. This tutorial is gold as others said. Thank you. I am a beginner so I could not get the point of putting the refresh token after user logs out. We already clean localstorage so if we did not put the reflesh token in blacklist how would the user could log in ?
@veryacademy
@veryacademy 3 жыл бұрын
Hi C D - sorry, please could you simplify that question for me.
@ironheadmedia1625
@ironheadmedia1625 3 жыл бұрын
@@veryacademy Thank you for the quick reply. My question is that 'when user logs out, we clean localstorage so this user can not be able to log in anymore with the token that we just deleted from localstorage. So after we deleted tokens in localstorage , why should we put the "tokens" in blacklist ? Is it for security reasons? '
@cje8887
@cje8887 2 жыл бұрын
@@ironheadmedia1625 I believe the reason is related to the statelessness - sure we deleted the token, but if anyone else (such as a malicious entity) still has access to the token, they could then just keep using it, because the server doesn't know that the user has logged out / deleted their token. Of course having a blacklist kind of defeats the "statelessness" purpose of JWTs, but that's an entirely separate debate and you can find many videos of people arguing about the pros and cons of session auth vs JWTs
@AhmedAli-oc3xp
@AhmedAli-oc3xp 3 жыл бұрын
I'm having trouble in setting Postman as it continuously showing.. { "email": [ "This field is required." ], "password": [ "This field is required." ] } Thanks in advance!!!
@veryacademy
@veryacademy 3 жыл бұрын
It is telling you that Django is expecting that data and you need to define it in your frontend to pass that data to Django.
@AhmedAli-oc3xp
@AhmedAli-oc3xp 3 жыл бұрын
@@veryacademy Thanks a lot!!! I just figured out the problem...
@indojojon892
@indojojon892 3 жыл бұрын
I have a question. How does the frontend recognize if the user is logged in or not?
@veryacademy
@veryacademy 3 жыл бұрын
Behind the scenes when you log in a cookie is created on your browser. The information in the cookie is sent every time you make a request to the server. The cookie holds a session number which matches a session on the django server. If the session number in your cookie matches the session on the server we could then determine the user is logged in. When you log out django destroys the session (this data can be store in a number of places, by default in the database). In the cookie data also if your user ID - so we can determine who you are.
@indojojon892
@indojojon892 3 жыл бұрын
@@veryacademy do you have the video for that?
@madhanpokhrel9233
@madhanpokhrel9233 9 ай бұрын
is anyone getting error in there simple jwt..... i cant run my runserver
@mehboobshaikh8396
@mehboobshaikh8396 3 жыл бұрын
can you make a video on how to integrate django rest framework with keycloak?
@veryacademy
@veryacademy 3 жыл бұрын
hmm noted it down
@mehboobshaikh8396
@mehboobshaikh8396 3 жыл бұрын
@@veryacademy Thank You....Please make it ASAP.
@satishkurakula
@satishkurakula 3 жыл бұрын
Hi, I'm not able to see auth tokens in the inspect - > Application any help. not able to get the storage tab as you got in the video.
@veryacademy
@veryacademy 3 жыл бұрын
Hi there - I am using just the latest version of chrome - should be all standard (f12 then Application then Storage)
@satishkurakula
@satishkurakula 3 жыл бұрын
@@veryacademy in mozilla there was no storage option in the application menu but in chrome I was able to get it.
@veryacademy
@veryacademy 3 жыл бұрын
@@satishkurakula Great 👍
@kevinconnaughton9756
@kevinconnaughton9756 2 жыл бұрын
Good morning. thank you for your course's. I don't know if you are going to see this. but i have a issue with postman, in spite of going over my code with fine tooth comb. I keep getting this message "detail": "Authentication credentials were not provided." can you please help
@veryacademy
@veryacademy 2 жыл бұрын
Hi Kevin, only suggestion is that when you send a request you haven’t included authentication details, user pass and possibly token. Just double check you are passing everything over and have put the data in the right place and in the right format when sending it
@alkfalfnsflgjslfj2127
@alkfalfnsflgjslfj2127 3 жыл бұрын
can we do this without creating custom user model and using django built in user model?
@veryacademy
@veryacademy 3 жыл бұрын
Sure you can - thanks for all the questions
@alkfalfnsflgjslfj2127
@alkfalfnsflgjslfj2127 3 жыл бұрын
Could you please do with allauth and react ??
@ummehanyarozshandaanny2846
@ummehanyarozshandaanny2846 2 жыл бұрын
my sign up, sign in form is not showing what to do? someone plz help
@veryacademy
@veryacademy 2 жыл бұрын
Thank you Umme, sorry I cant help you directly. Needless to say, keep comparing the code from the repository with your own code if you are working directly from the example.
@ummehanyarozshandaanny2846
@ummehanyarozshandaanny2846 2 жыл бұрын
@@veryacademy Hello, I did with your source code as well. and react-dom new version doesn't support switch. So I followed the online help and used Routes but header footer is working not the body part. I mean sign in or sign up form. thanks
@markchukwuebuka6814
@markchukwuebuka6814 3 жыл бұрын
hello, when i tried posting data with Postman using this endpoint "127.0.0.1:8000/api/user/register/", this was the response i got : {"detail":"Unsupported media type \"text/plain\" in request."}
@veryacademy
@veryacademy 3 жыл бұрын
hey see answer in your other comment
@oscarparedez1417
@oscarparedez1417 3 жыл бұрын
Any place I can find the Axios Instance adapted to React Native?
@bawer_my
@bawer_my Жыл бұрын
thank you
@MrKeepItTrill
@MrKeepItTrill 2 жыл бұрын
Thanks for another great tutorial! One thing I noticed is, when a token gets put on the blacklist it still remains in the Outstanding Tokens as well. Is this intentional in terms of how JWTs work?
@veryacademy
@veryacademy 2 жыл бұрын
Yeah there is a bit of work that needs doing, it’s not the cleanest.
@harshitgangwar2162
@harshitgangwar2162 3 жыл бұрын
Posts are not loading even after i have recieved the acces and refresh tokes, when i redirect to '/' console says unauthorized, please helpp
@veryacademy
@veryacademy 3 жыл бұрын
Hi, it can be difficult to line up everything to get it working. This isnt going to sound useful but, try and follow the process stage by stage and use print() in Django and console.log in JS to help output information that could help you determine where the problem is. unauthorized - this is suggesting that even though you have your tokens, when you request data - maybe you are not requesting it in the correct manor - or maybe your permissions need to be checked. If you use Postman - try on there - sometimes it gives you better feedback/info in the console by default.
@harshitgangwar2162
@harshitgangwar2162 3 жыл бұрын
@@veryacademy Hey thanks, I found a typo, silly of me. But thanks anyway you are so great, people rarely take time out to read comments and help others. Also, this series is THE BEST right now on youtube fir DRF+React, its going to be a hit.
Session Vs JWT: The Differences You May Not Know!
7:00
ByteByteGo
Рет қаралды 118 М.
王子原来是假正经#艾莎
00:39
在逃的公主
Рет қаралды 16 МЛН
나랑 아빠가 아이스크림 먹을 때
00:15
진영민yeongmin
Рет қаралды 4 МЛН
When RESTful architecture isn't enough...
21:02
Dreams of Code
Рет қаралды 273 М.
Authentication & Refreshing Tokens Implementation
2:09:53
Dennis Ivy
Рет қаралды 233 М.
The Big Headless CMS Lie (James Mikrut)
18:14
Vercel
Рет қаралды 56 М.
王子原来是假正经#艾莎
00:39
在逃的公主
Рет қаралды 16 МЛН