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
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.
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.
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 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 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 !
Thank you for watching this video.
*Buy my keyboard:* amzn.to/46lefoL
I have have such many videos up to no avail... this your video save my project,,,, thank you so much
Glad it helped!
Please do susbcribe for more such content.
Really well-explained and thorough guide 10/10. Thank you so much!!
Glad you liked it!
Thanks so much, i needed it
Glad it helped
Explain with font end part also how to render data in temple
Sure! Will do soon.
what's next after this, how should I integrate this into my web app. or is there another for logout? and register?
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
*Django Rest Framework User Registration (Signup)* : th-cam.com/video/4Azu7AX0mls/w-d-xo.html
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
I tried to get new tokens for admin and it worked! I was able to create new user through postman! Thanks
@@athulyajose Can you give the solution. I'm facing same issue
Create a new superuser from django shell.
Login as superadmin.
Generate a token and use that token in the postman.
At 15:40 I am still getting "{
"detail": "Authentication credentials were not provided."
}" stuck since morning, plese help
While doing the AJAX request, please provide the token
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.
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.
Hello can I ask what is the purpose of this and how should I proceed after following this
This is the main logic of how login works using REST API. now you can use this anywhere (eg. front-end app, mobile app)
Everything is greate, but can anyone tell me that how can any user can login using Username and password within Postman
it is very easy.
In "Authorization" select "Basic Auth" and you will get option to enter username and password
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 ?
You can login from superuser and check if that user is active or not and then try to generate the token.
@@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!
okay, please do post the link here as well.
@@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 !
Nice to hear that!
👍👌
question here, why you does not encrypt the password?
Hi..how can i use this api in frontend like on a html,css login page
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
how do you open api tokens and others,,it doesnt show on my
If you see the settings.py, I have specified REST_FRAMEWORK configuration.
Please use that then api token will be visible.
Nice video! 😃
Thank you
why would i need a token to register a user?
We don't need token to register user
Make. Video on youtube
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.
I found the error, it was that I wrote permission_class = (IsAuthenticated,) instead of permission_classes = (IsAuthenticated,)
Glad to hear that you were able to find and fix the problem