JSON Web Tokens With Django REST Framework

Поділитися
Вставка
  • Опубліковано 3 лют 2025

КОМЕНТАРІ • 116

  • @prettyprinted
    @prettyprinted  5 років тому +4

    Join my free course on building a Todo API with Django REST Framework: prettyprinted.com/djangotodoapi

  • @aldemarocruz9668
    @aldemarocruz9668 2 роки тому

    I think this is the best video with django anfd JWT

  • @auroshisray9140
    @auroshisray9140 3 роки тому

    Thanks man...for the simple explanation

  • @minsukwon3833
    @minsukwon3833 5 років тому +2

    loved watching your series! thanks a lot

  • @Myskyink
    @Myskyink 6 років тому

    I have been following you since my days of learning flask. Your tutorials are simply the best. Please make videos on authentication, permission .

    • @prettyprinted
      @prettyprinted  6 років тому

      Will definitely cover those topics. Thanks for watching!

  • @dutchprime1488
    @dutchprime1488 3 роки тому

    Great tutorial, it helped me understand how the package works!

  • @medoabdin480
    @medoabdin480 4 роки тому

    you are amazing Anthony you have a very good explanation style. bless you god

  • @johnquick7275
    @johnquick7275 4 роки тому

    Outstanding video and explanation. Thank you.

  • @alexlindgren1
    @alexlindgren1 3 роки тому

    Great tutorial series, really appreciated it!

  • @tomouyt
    @tomouyt 6 років тому

    Great tutorial, straight to the point and with very good explanations.

  • @ABMA79
    @ABMA79 Рік тому

    My dear friend, I am a great fan of your youtube channel since I am an intermediate Django framework user. I do have a question, when do we need to make API for our application? from What I have seen, it is not obligatory unless you plan to share data with other entities or end users. So can you please tell me the goal of enabling API briefly?

  • @mrmuranga
    @mrmuranga 4 роки тому +1

    awesome.... thanks

  • @AryanGNU
    @AryanGNU 4 роки тому

    You are awesome man, Thanks a ton

  • @veziop
    @veziop 3 роки тому

    so if i understand correctly, this is a way of proviging an 'API token' for the users of our django REST API once we deploy it? I imagine in our documentation we include a step for acquiring the tokens only if the user inputs the relevant data into a POST method to '/api/token/' just as shown in this video. am i correct or am i missing something?

  • @fabricioaugusto6324
    @fabricioaugusto6324 6 років тому +3

    You saved my life. Thank you!

  • @MiRaje8086
    @MiRaje8086 3 роки тому

    thank you so much man

  • @thomasshowers6682
    @thomasshowers6682 6 років тому +1

    I think the reason your signature was invalid on jwt.io is because you weren't using the secret from your settings.py file. When you toggle the 'secret base64 encoded' option it creates a new token using "secret" as the secret (10:50). If you put the secret from settings.py in that box and paste your token again it should work with 'secret base64 encoded' unchecked.

  • @johncollera
    @johncollera 4 роки тому

    Can you write the code to POST and get the the token... so the code will automatically get the JWT and then use that to return the data

  • @nguyenconghuy3847
    @nguyenconghuy3847 2 роки тому

    how can I declare which api need access token and which doesn't in django

  • @DANJUMA9
    @DANJUMA9 6 років тому

    Simple and short!!

  • @jonathanma4501
    @jonathanma4501 4 роки тому +1

    Hi, this was a great video. I have a question - like in the video, you created an access/refresh token with a given username and password. But what if you want to only allow some users to make the access/refresh token? For example, only paid users, or only users who have registered as an account? Would I have to implement logic in the views so that it checks with a database for preexisting users, or do I have to create a signed url to get access to make the token? What's the best way of restricting token creation? Or, should I have only a server side application connect to this resource api to create the access/refresh token, which I then pass to the frontend as a response?

    • @veziop
      @veziop 3 роки тому

      i find this question interesting

    • @abhishektayal480
      @abhishektayal480 2 роки тому

      For that we have to use permissions along with jwt.

  • @mrmuranga
    @mrmuranga 5 років тому

    Really simple to use......thanks Anthony...
    Compared with Django Rest Knox would you say JWT is more secure or faster ?

  • @kutluaydn1508
    @kutluaydn1508 3 роки тому

    I don't want to use library for jwt. Is there any source for python jwt?

  • @akshhay
    @akshhay 5 років тому +1

    How to implement this in a form in django?

  • @dgiri2333
    @dgiri2333 5 років тому

    Hi how to create nested serializer like if select district then it's show model list ,if model select all village can show on villages how to implement

  • @hariprakasham
    @hariprakasham 4 роки тому

    hi I have a doubt .. from where you referred paradigms .. ?? this the source of paradigms is not displayed in this video ..

  • @politicallynotcorrect2968
    @politicallynotcorrect2968 4 роки тому

    how do i create a routh only for auth users

  • @dcatalyst6271
    @dcatalyst6271 4 роки тому

    hey can you make a Django snowflake database connection video I have searched allot but not found the solution anywhere

  • @serhii.chumachenko
    @serhii.chumachenko 6 років тому +3

    It's awesome! Thanks!

  • @ZainAli-me4qk
    @ZainAli-me4qk 5 років тому

    Can you please tell me how to create multi-users like Sellers buyers and admin with their roles i need model and serializers for 3 users model. Please help

  • @sabitmahmud7652
    @sabitmahmud7652 6 років тому +1

    hello Anthony !!As SuperUser can create lots of user according to their roll but Using JWT with DRF returns a response for Refresh and Access token. But it is impossible to define which user it is ! How can I return or pass a value by which I can able to understand what type of user it is?

  • @stanleyjohn4670
    @stanleyjohn4670 5 років тому

    I want to use a LOGOUT API that logs out the current user and deletes/removes the existing access token. The access token has an expiration date of 1 year (my requirement) but can be deleted/expire once a user logs out. How can I do this?

  • @msasoftware
    @msasoftware 5 років тому

    :) Excelent. Thanks you so much

  • @harshilgohil3918
    @harshilgohil3918 5 років тому +1

    Hello!, After installing djangorestframework_simplejwt and after updating 'DEFAULT_AUTHENTICATION_CLASSES' in settings.py and adding proper imports in urls.py .I am getting a ModuleNotFoundError: No module named 'rest_framework_simplejwt'. Is there any other dependency I need to install?
    Thanks in advance!

    • @stev3886
      @stev3886 5 років тому +1

      Did you install it in the right virtual environment? sometimes people made this mistake

  • @MrIgorbpf
    @MrIgorbpf 6 років тому

    Great video, man! Could u do a series using djoser and JWT of the whole process of authentication? I men signup, login, password reset, email and etc. That would be awesome!

    • @prettyprinted
      @prettyprinted  6 років тому +1

      I'll look into djoser. Thanks for the idea.

    • @abirulezz
      @abirulezz 6 років тому +1

      oh yeah please do!

  • @CerebroVasconcelos
    @CerebroVasconcelos 5 років тому

    Thanks for to do this video

    • @prettyprinted
      @prettyprinted  5 років тому

      You're welcome! Thanks for watching.

  • @toufanialfarisi1866
    @toufanialfarisi1866 5 років тому

    it's really really awesome

  • @wayneloo8234
    @wayneloo8234 6 років тому

    That's really cool. But I think the user login is validating against the user model in the database. What if we're using external methods like ldap? How does it work? Do you have a video on that?

    • @prettyprinted
      @prettyprinted  6 років тому

      No video on ldap, but I'll consider it for the future.

  • @victorazuara3346
    @victorazuara3346 6 років тому

    Excellent, thank you

    • @prettyprinted
      @prettyprinted  6 років тому +1

      You're welcome. Thanks for watching.

  • @highskill
    @highskill 6 років тому +1

    Thank you! 🙌

  • @whateverreally
    @whateverreally 4 роки тому

    Hey dude, I'm getting an error, just gonna paste it here:
    HTTPConnectionPool(host='127.0.0.1', port=8000): Max retries exceeded with url: /authors (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused',))
    This occurs when I'm tryna run the send.py file. Can you let me know what I can do? I kinda need help asap. Thanks bruh.

    • @whateverreally
      @whateverreally 4 роки тому

      FYI, I did not use POSTMAN, I got the token directly from the website after I entered the login credentials.

  • @amirshehzad3352
    @amirshehzad3352 6 років тому

    @Pretty Printed How are you connecting python in Ubuntu Bash with VScode?

    • @prettyprinted
      @prettyprinted  6 років тому

      I don't actually. I keep them separate. I eventually need to connect them though.

  • @nurizzati5892
    @nurizzati5892 6 років тому

    i hope you do token based authentication with django rest framework

    • @prettyprinted
      @prettyprinted  6 років тому

      I'll probably cover that in the future.

  • @chesterholt5551
    @chesterholt5551 6 років тому

    Superb

  • @blog.pymastery
    @blog.pymastery 5 років тому

    Everything is well done. However, why I can't access Django Database essential, it says that 404 page not found !?
    Help, please.

  • @ChantOfSpirit
    @ChantOfSpirit 5 років тому

    Author, what I should do with {% csrf_token %} template tag ? I can't remove it... How I can use my login/logout forms with new token?

  • @ahadulislam8891
    @ahadulislam8891 5 років тому

    Nice Video bro. But is there any way to use JWT without DRF(Django Rest Framework ). Thank You

    • @prettyprinted
      @prettyprinted  5 років тому

      Yeah, check out my JWT videos with Flask. The concept will be the same in Django.

  • @sankarbathula8758
    @sankarbathula8758 6 років тому

    Thanks a lot...!

    • @prettyprinted
      @prettyprinted  6 років тому

      You're welcome! Thanks for watching.

  • @swaali1
    @swaali1 6 років тому

    hello , can i use it for cb token adder thankssssssssssssss

  • @alexanderlabrador5608
    @alexanderlabrador5608 6 років тому

    how can I consume this api from a fronent or an html with ajx ?

  • @nagaraja4846
    @nagaraja4846 5 років тому

    how can i generate jwt custom token for django api...Thank You Advance.

  • @frostsmaker8966
    @frostsmaker8966 4 роки тому

    How to get user_id from the access token/ authenticated user in views.py?? I want to use the object manager to get data using user_id.

  • @manhha3010932
    @manhha3010932 6 років тому

    Hi! I'm counfusing after learn Django Rest framework, what django REST do? how to render those data to front end? because this is just pure data, how to use it in front? I am beginer so sorry if dumb question, thanks !

    • @prettyprinted
      @prettyprinted  6 років тому

      If you want to display data, you can use the traditional template features of Django. Another way to render pure data is by using a frontend framework like React. I recommend looking into templates first though.

  • @sumitprakash2747
    @sumitprakash2747 4 роки тому

    Hi I am getting
    ModuleNotFoundError at /
    No module named 'rest_framework_simplejwt'

  • @kancharlanikhilsai9838
    @kancharlanikhilsai9838 6 років тому +1

    I was looking for this type of video and got yours. Excellent video. Thank you so much.
    The username and password are from auth_user table in db. Is there any way to take username and password from another table we create for storing users.

    • @prettyprinted
      @prettyprinted  6 років тому

      Everything in DRF can be customized, but it takes more code. But yeah, you can change to a different database.

    • @kancharlanikhilsai9838
      @kancharlanikhilsai9838 6 років тому +1

      where to modify the code to get the user details along with the tokens generated.

    • @mdk124
      @mdk124 5 років тому

      @@prettyprinted Is there a direction that we can look at for this?

    • @mdk124
      @mdk124 5 років тому

      @@kancharlanikhilsai9838 Hi! Did you manage to solve this issue you were facing?

  • @georgesmith3022
    @georgesmith3022 6 років тому +1

    by default, for how long is the token valid?

    • @prettyprinted
      @prettyprinted  6 років тому +1

      Five minutes. You can see the defaults here: github.com/davesque/django-rest-framework-simplejwt#settings

    • @georgesmith3022
      @georgesmith3022 6 років тому

      @@prettyprinted thanks

  • @georgesmith3022
    @georgesmith3022 6 років тому

    are the google api keys jwt tokens?

    • @prettyprinted
      @prettyprinted  6 років тому +1

      No, they're tokens specific to Google.

    • @georgesmith3022
      @georgesmith3022 6 років тому

      @@prettyprinted thanks for answering

  • @JonesDTaylor
    @JonesDTaylor 6 років тому

    Hi Anthony
    Your videos are nice. Can you please show the audiance where do you get your code from ? for instance the settings.py changes for token authentication. It helps if you show the location (obviousily from the official doc of restframework) from which you get the code. Thank you

    • @prettyprinted
      @prettyprinted  6 років тому

      It's not practical for me to give all the locations in the docs, but the extension's documentation isn't too complicated so you should be able to see if it you go to the relevant section.

  • @rayaangrewal1035
    @rayaangrewal1035 5 років тому

    awesome

  • @Skaxarrat
    @Skaxarrat 6 років тому +1

    I did this series two times, from scratch, but when I get to this point I start to have issues. I've 'pip installed' rest_framework_simplejwt', added it to settings.py and created the two endpoints to 'api/token' and 'api/token/refresh', yet I still don't get the 'Authentication credentials are not provided' message. Anyone is having the same issue as me and fixed it?
    Keep in mind I've tried this two times from scratch

    • @fester6537
      @fester6537 6 років тому

      From what I can tell your permission is set to 'permissions.IsAuthenticatedOrReadOnly' instead of 'permissions.IsAuthenticated'. It should works if you change both permission in your settings.py and your LanguageView.

    • @niteshrawat576
      @niteshrawat576 6 років тому

      are declaring permission class as AllowAny or authentication class as IsAuthorizedOrReadOnly? If yes, then please don't.

    • @davidmutua6971
      @davidmutua6971 5 років тому

      Actually this is not a problem you must make sure first your local django development server is running. The message may vary like mine too doesn't show that when I post using postman but it does when using "Insomnia" software. It's similar to postman but simpler. Postman is a beast though.

  • @learnwithfun147
    @learnwithfun147 6 років тому

    Hey Pretty good job man. Can you do Class Based View tuths. Waiting for it :)

    • @prettyprinted
      @prettyprinted  6 років тому +1

      Yep, that's on the list. Thanks for watching.

  • @amangautam6662
    @amangautam6662 5 років тому

    When i'm trying to get access token and refresh token using curl command curl -X POST -H "Content-Type: application/json" -d '{"username":"myusername", "password":"mypassword"}' localhost:8000/api/token/
    i'm getting error username and password this field is required but it is working with postman api testing

  • @xtremehackerzpro9511
    @xtremehackerzpro9511 6 років тому

    Excellent :)

  • @shubhamkumar9484
    @shubhamkumar9484 5 років тому +2

    from where paradigms came i lost it there

  • @bravmi
    @bravmi 6 років тому

    You rock dude

  • @SidonDuarte
    @SidonDuarte 6 років тому

    What is the differences between "django-rest-framework-jwt' and "django-rest-framework-simplejwt ( github.com/davesque/django-rest-framework-simplejwt ), what its advantages and drawbacks for each one?

    • @prettyprinted
      @prettyprinted  6 років тому +1

      Generally the differences between any similar libraries are just the patterns. So try out both and see which pattern you like best.

  • @christianmagnus1003
    @christianmagnus1003 4 роки тому +1

    Hello buddy, i have a questions, that username and password was by the Admin user really? i mean that token is only for superuser in django rest framework, not for normal users yes?

    • @huzaifquazi
      @huzaifquazi 4 роки тому

      how can i get token for user and not admin ?

  • @oluwafemimatthew3501
    @oluwafemimatthew3501 6 років тому

    Is there any reason behind your choice of github.com/davesque/django-rest-framework-simplejwt as against a more established github.com/GetBlimp/django-rest-framework-jwt. Nice video by the way, clear and concise

    • @prettyprinted
      @prettyprinted  6 років тому

      No particular reason. If you can use, then you should be able to figure out the other. Thanks for watching.

  • @msasoftware
    @msasoftware 5 років тому

    More options in: www.django-rest-framework.org/api-guide/authentication/#third-party-packages

  • @gopalsivethna2959
    @gopalsivethna2959 6 років тому

    hello sir i am brown person and u r smartents black person i know, thanks for the help!

  • @estebanmejia9989
    @estebanmejia9989 5 років тому

    Great, please enumerate your videos.

  • @eduardorodriguezperez704
    @eduardorodriguezperez704 6 років тому

    pip install djangorestframework_simplejwt

  • @eshaanbansal9122
    @eshaanbansal9122 4 роки тому

    Flask > Django.