Questions tagged [django-rest-knox]

45 questions
0
votes
2 answers

I am trying to authenticate the the USER model for Register and Login API in Django REST framework. I am getting the following error msg

"detail": "Authentication credentials were not provided." I have tried all the available internet solutions, added the REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES':( 'knox.auth.TokenAuthentication', …
0
votes
0 answers

Create accounts and API tokens for live mode and test mode

I want to create a system that works similar to stripe. There'll be live API keys, as well as test API keys. I have been thinking of how to implement this architecture, and I am not sure the best way to go about it. I found a similar question on…
0
votes
0 answers

How to handle "204 no content" response with Retrofit after logout?

In my Android app, I have the following logout function: suspend fun logout(token: String): NetworkResult { return try{ val logoutResponse = service.logout("Token $token") NetworkResult.Success(logoutResponse) …
0
votes
1 answer

why am I getting forbidden error on my URL routes for login DRF API?

I have created a simple login API through django rest framework. Below is the code snippet: views.py from rest_framework.authtoken.serializers import AuthTokenSerializer from rest_framework.permissions import IsAuthenticated, IsAdminUser,…
user3521180
  • 1,044
  • 2
  • 20
  • 45
0
votes
1 answer

Why in an AllowAny view of Django I get 401 Unauthorized using Firefox but not using Edge or Postman?

I'm using knox LoginView to make the login of my backend. This is the code of the view: class Login(LoginView): permission_classes = (AllowAny,) def post(self, request, format=None): serializer =…
0
votes
2 answers

How to get results of only the primary key and not all results in django-rest-framework?

In my django app, i need to check if a user exists using a phone number. The login is done using phone number and OTP. I can check if the user exists by a get request to "/api/profiles//". However if I request "/api/profiles/" i…
0
votes
1 answer

How to pass in the token for authorization in between React pages (in a Django Knox setup)?

I have 2 components/pages. One is the login page and one is the user customization page. I want the user customization page to be token authorized so you can only see it after you login. I am using a Django + React setup with Django Knox being used…
usernaame001
  • 129
  • 1
  • 1
  • 9
0
votes
0 answers

get the error 'Authentication credentials were not provided' even after passing the token in the headers

UPDATE i just added this to my settings.py: REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.BasicAuthentication', **<--THIS!** 'knox.auth.TokenAuthentication', ), } now i get this when i'm…
0
votes
1 answer

cant sign in user, not getting the right response, trying to get user with token

Im having a lot of problems in my first django, rest-framework application. Im not getting the token after Im signing up, instead of "user" : { "_id":"1", "username":"you", "email":"a@a.com" }, "token" : 'fjdjfkljgkghgjkl' } Im…
Circus4
  • 301
  • 2
  • 5
  • 13
0
votes
0 answers

I see Login page for a fraction of a second, then gets redirect to the lead form

I am trying to integrate react with django for this I am referring to one of the course by Brad where he used django with react[https://www.youtube.com/watch?v=kfpY5BsIoFg&list=PLillGF-RfqbbRA-CIUxlxkUpbq0IFkX60&index=7]. I am using HashRouter as…
0
votes
1 answer

DRF and Knox Authentication: Allow login for non-staff users

I have created a Login API which authenticates users from django.contrib.auth.models.User. I am using DRF and implementing a token authentication with django-rest-knox and so far so good. The application I am developing is a bit complicated but I'm…
Michael
  • 335
  • 1
  • 22
0
votes
1 answer

Django/knox backend login failing even when given proper username and password

I'm building user authentication in Django using the built-in user model and knox token authentication. Through postman, I'm able to create a new user which properly returns the username and a unique token for that user. However, when I attempt to…
0
votes
1 answer

Syntax Error after adding knox to urls.py

I am new to Django and django-rest-framework. I am building an API and I want to implement auth using Django-rest-Knox. I have added Knox to the installed apps in the settings.py. In the urls.py of the project, I added the path to Knox. It seems…
Osborne Saka
  • 469
  • 1
  • 4
  • 21
0
votes
2 answers

Unable to use token authentication as the only authentication class in django-rest-knox with custom user model

I am using django-rest-knox for user authentication and have knox.auth.TokenAuthentication as the only authentication class. Also, I am using custom user models by extending AbstractBaseUser. I have email and password as fields for logging…
Vineet
  • 723
  • 4
  • 12
  • 31
-1
votes
1 answer

Mapping access token to client IP

My Setup I am using React and Django as frontend & backend. For authorization purposes I chose Django-rest-knox, which works via tokens stored in a database. My Problem Now if an attacker gets a hold of the token (stored in local storage on the…
1 2
3