Build Login API in Django and Django Rest Framework || How to

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 พ.ย. 2024

ความคิดเห็น • 46

  • @CodewithSJ
    @CodewithSJ  ปีที่แล้ว +1

    Thank you for watching this video.
    *Buy my keyboard:* amzn.to/46lefoL

  • @chrissati6713
    @chrissati6713 3 หลายเดือนก่อน +1

    I have have such many videos up to no avail... this your video save my project,,,, thank you so much

    • @CodewithSJ
      @CodewithSJ  3 หลายเดือนก่อน

      Glad it helped!
      Please do susbcribe for more such content.

  • @vvxyow2400
    @vvxyow2400 ปีที่แล้ว

    Really well-explained and thorough guide 10/10. Thank you so much!!

    • @CodewithSJ
      @CodewithSJ  ปีที่แล้ว +1

      Glad you liked it!

  • @RandomMusicD
    @RandomMusicD ปีที่แล้ว +1

    Thanks so much, i needed it

  • @ridersofficial5638
    @ridersofficial5638 3 หลายเดือนก่อน +1

    Explain with font end part also how to render data in temple

    • @CodewithSJ
      @CodewithSJ  3 หลายเดือนก่อน

      Sure! Will do soon.

  • @deed_it
    @deed_it ปีที่แล้ว

    what's next after this, how should I integrate this into my web app. or is there another for logout? and register?

    • @CodewithSJ
      @CodewithSJ  ปีที่แล้ว

      Yes, this is to be integrated in any mobile app or front-end app.
      Registeration video: th-cam.com/video/4Azu7AX0mls/w-d-xo.html

  • @CodewithSJ
    @CodewithSJ  2 ปีที่แล้ว +1

    *Django Rest Framework User Registration (Signup)* : th-cam.com/video/4Azu7AX0mls/w-d-xo.html

  • @athulyajose
    @athulyajose 9 หลายเดือนก่อน +1

    17:45 I tried to POST but I’m getting the output containing detail code ans messages where the detail contains- “given token not valid for any token type”. Also i cant add tokens in the local host

    • @athulyajose
      @athulyajose 9 หลายเดือนก่อน +1

      I tried to get new tokens for admin and it worked! I was able to create new user through postman! Thanks

    • @thorodinson8187
      @thorodinson8187 8 หลายเดือนก่อน +1

      ​@@athulyajose Can you give the solution. I'm facing same issue

    • @CodewithSJ
      @CodewithSJ  7 หลายเดือนก่อน

      Create a new superuser from django shell.
      Login as superadmin.
      Generate a token and use that token in the postman.

  • @noscopedemon4308
    @noscopedemon4308 ปีที่แล้ว +1

    At 15:40 I am still getting "{
    "detail": "Authentication credentials were not provided."
    }" stuck since morning, plese help

    • @CodewithSJ
      @CodewithSJ  ปีที่แล้ว

      While doing the AJAX request, please provide the token

  • @salmanr
    @salmanr 2 ปีที่แล้ว

    Hey, one doubt, So here "api/token" is the main login API and "/user" is used to get the details of the user? Am i correct? and also how we can access other user information with only one bearer token? its wrong right?
    And let say i want to register new user, how user will get token that time?
    I am new to Django please help.

    • @CodewithSJ
      @CodewithSJ  2 ปีที่แล้ว

      So here "api/token" is the main login API and "/user" is used to get the details of the user? Am i correct?
      Yes, this is correct.
      and also how we can access other user information with only one bearer token? its wrong right?
      I think you just have to do a retrieve API call with a specific user id, and users id's can be found from the list API
      No, I don't think it is wrong. Usually, admins have to do such a thing.
      And let say i want to register new user, how user will get token that time?
      Technically this should be possible, but since we are using the plugin so after the registration of the user, you will have to explicitly call the plugin's internal methods which will generate the token, and then you will have to return the token to the user.

  • @deed_it
    @deed_it ปีที่แล้ว

    Hello can I ask what is the purpose of this and how should I proceed after following this

    • @CodewithSJ
      @CodewithSJ  ปีที่แล้ว

      This is the main logic of how login works using REST API. now you can use this anywhere (eg. front-end app, mobile app)

  • @kahi_chalte_hain___
    @kahi_chalte_hain___ ปีที่แล้ว +1

    Everything is greate, but can anyone tell me that how can any user can login using Username and password within Postman

    • @CodewithSJ
      @CodewithSJ  ปีที่แล้ว

      it is very easy.
      In "Authorization" select "Basic Auth" and you will get option to enter username and password

  • @mista_ia
    @mista_ia 2 ปีที่แล้ว +1

    Amazing.. First Thanks for that !
    I am using custom user (extended from AbstractBaseUser) and I have users in my DB with all requirements (is_active, hashed password, etc.) but when I enter credentials (email as username and password) to token view I am still getting "No active user with those credentials."
    Any Help please ?

    • @CodewithSJ
      @CodewithSJ  2 ปีที่แล้ว +1

      You can login from superuser and check if that user is active or not and then try to generate the token.

    • @mista_ia
      @mista_ia 2 ปีที่แล้ว +1

      @@CodewithSJ all the users are active, I believe that the problem lays on the fact that I have extended the original user model since none of login works (from /admin, browsable api of DRF, or even a login view I created for test).
      I will open a stack for better understanding!

    • @CodewithSJ
      @CodewithSJ  2 ปีที่แล้ว

      okay, please do post the link here as well.

    • @mista_ia
      @mista_ia 2 ปีที่แล้ว +2

      @@CodewithSJ Nevermind. My bad, I was hashing the password twice with set_password and make_password while I do not even need them since I am using the default UserManager.
      Thanks for assist !

    • @CodewithSJ
      @CodewithSJ  2 ปีที่แล้ว +1

      Nice to hear that!

  • @classicclassic1474
    @classicclassic1474 2 ปีที่แล้ว

    👍👌

  • @19betim
    @19betim 2 ปีที่แล้ว

    question here, why you does not encrypt the password?

  • @gokulsuresh1888
    @gokulsuresh1888 2 ปีที่แล้ว

    Hi..how can i use this api in frontend like on a html,css login page

    • @CodewithSJ
      @CodewithSJ  2 ปีที่แล้ว

      Hey,
      For that we will have to create Javasctip function and use AJAX/AXIOS to call the APIs from the frontend and send and/or receive data

  • @abhishekozha8555
    @abhishekozha8555 ปีที่แล้ว

    how do you open api tokens and others,,it doesnt show on my

    • @CodewithSJ
      @CodewithSJ  ปีที่แล้ว

      If you see the settings.py, I have specified REST_FRAMEWORK configuration.
      Please use that then api token will be visible.

  • @adwaitahegde
    @adwaitahegde 3 ปีที่แล้ว +1

    Nice video! 😃

  • @martinwanjia990
    @martinwanjia990 2 ปีที่แล้ว

    why would i need a token to register a user?

    • @CodewithSJ
      @CodewithSJ  2 ปีที่แล้ว

      We don't need token to register user

  • @sandeepmishra1390
    @sandeepmishra1390 3 ปีที่แล้ว

    Make. Video on youtube

  • @mattiastofte7457
    @mattiastofte7457 2 ปีที่แล้ว

    Hi, everything works except that you get HTTP 200 OK (Allow: GET, POST, etc.) on localhost:8000/user/ even if you are not logged in.

    • @mattiastofte7457
      @mattiastofte7457 2 ปีที่แล้ว +1

      I found the error, it was that I wrote permission_class = (IsAuthenticated,) instead of permission_classes = (IsAuthenticated,)

    • @CodewithSJ
      @CodewithSJ  2 ปีที่แล้ว

      Glad to hear that you were able to find and fix the problem