216 questions
1
vote
2
answers
795
views
Unauthorized response to POST request in Django Rest Framework with Simple JWT
I am doing a project with REST API and Django Rest Framework. I currently have an issue in my post request where some of my endpoints return HTTP 401 Unauthorized, though all other get or update ...
-1
votes
2
answers
1k
views
Login error InvalidTokenError: Invalid token specified: must be a string
I am currently a student working on my project and i am having a bit of trouble with my signin page.
when I attempt to sign in, I receive a 200 HTTP response indicating that successful sign in to the ...
0
votes
1
answer
207
views
dj-rest-auth/login doesn't work with 'DEFAULT_AUTHENTICATION_CLASSES': [ 'rest_framework_simplejwt.authentication.JWTAuthentication',], in postman
I am not an expert of setting up the settings file in DRF. I want to use React and DRF for authentication and this is my code
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
...
0
votes
2
answers
235
views
How to customize the default Token invalid json response in django for JWTAuthentication
In my django rest app i like to change the default error response from JWTAuthentication. Currently my application is using JWT With django to work on login and logout (which blacklists the token). ...
0
votes
0
answers
127
views
Expected view UserDetails to be called with a URL keyword argument named "pk"
models.py
class Customer(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
mobile = models.PositiveBigIntegerField(unique=True)
def __str__(self) -> str:
...
-1
votes
2
answers
69
views
Is it possible to get the all values of foreign key instead of id?
Is it possible to get all the values of foreign key instead of id?
class WishlistSerializer(serializers.ModelSerializer):
def to_representation(self, instance):
rep = super(WishlistSerializer, ...
1
vote
1
answer
472
views
Flutter and Django Login with JWT Tokens by storing tokens not working
I want to log in on Flutter, but it does not remain Authenticated in Django as well as on Flutter.
I just want the user to stay logged in on Flutter by storing tokens so it remains authenticated, but ...
1
vote
0
answers
82
views
I got this error :"No active account found with the given credentials" when i try to make jwt request
I'm trying to build a Rest Api Using Django.For the authentication i decide to use JWT but when i make a request using Postman, i got this error :
"detail": "No active account found ...
1
vote
1
answer
245
views
Request.user gives anonymous user in JWT
In my django rest framework project I used json web token based authentication and custom user model I want to access requested user object to pass as foreign key when I try request.user it will ...
0
votes
1
answer
2k
views
ImportError: cannot import name 'force_text' from 'django.utils.encoding'
from django.db import models
from django.contrib.auth.models import AbstractUser
class ExtendUser(AbstractUser):
email = models.EmailField(blank=False, unique=True)
EMAIL_FIELD = 'email
...
1
vote
1
answer
1k
views
Django REST framework smiple jwt add custom payload data and access it in route
I am generating a custom jwt token for authentication using RefreshToken.for_user(user) at the time of login and registration. I can access user using request.user in the API endpoint but I also want ...
1
vote
1
answer
579
views
Implementing Custom TokenBackend for rest_framework_simplejwt
I am migrating our Django code that uses djangorestframework-jwt to the latest version of djangorestframework-simplejwt(5.2.2) in Django 4.0.8. I am having an issue while trying to verify the token.
...
0
votes
4
answers
1k
views
detail": "Method \"GET\" not allowed. | Django Rest Framework
I'm following a course on user login and registration and I'm getting this error and I don't know how to fix it detail": "Method \"GET\" not allowed.
urls.py
from django.urls ...
0
votes
1
answer
756
views
djangorestframework-simplejwt not working
I'm following a Udemy Course with user administration and I need to install this
pip install djangorestframework-simplejwt
After its installed, I need to add this to settings.py
REST_FRAMEWORK = {
...
4
votes
2
answers
10k
views
ImportError: cannot import name 'ugettext' from 'django.utils.translation'
I installed djangorestframework as shown below:
pip install djangorestframework -jwt
Then, I used rest_framework_jwt.views as shown below:
from rest_framework_jwt.views import (
obtain_jwt_token, ...
2
votes
1
answer
130
views
View specified permission isn't replaced by default permission class
When I set default permission settings to
"DEFAULT_PERMISSION_CLASSES": [
"rest_framework.permissions.AllowAny",
],
and then define different permission for views like
...
1
vote
1
answer
4k
views
How to fix {detail: Authentication credentials were not provided.} in Django Rest Framework
I have struggling with getting information from Django rest framework as a backend and from the frontend using flutter.
The sequence of the project of the project is that I login and receive a {"...
0
votes
0
answers
582
views
JWT token expire successfully but still able to access Django API's
I'm using JWT token auth in django.
I set access-token timing to '1 minute' after 1-min the access & refresh token get expire and but when i try to access API url it gives access and show data.
i ...
0
votes
1
answer
1k
views
Django rest api create email login along with password
I've created the employee management system using django rest api. I've created the models, views and serializers like shown below. What i need is I've created employee details like his personal ...
1
vote
1
answer
392
views
Django rest framework create password for custom user model
Actually I'm creating an employee management system project using django rest api.
Now i have created my own custom models like shown below, i want to create the register employee with the below ...
1
vote
1
answer
435
views
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView
modules present in requirements.txt
asgiref==3.5.2
backports.zoneinfo==0.2.1
Django==4.0.5
djangorestframework==3.13.1
djangorestframework-simplejwt==5.2.0
PyJWT==2.5.0
pytz==2022.2.1
sqlparse==0.4....
0
votes
0
answers
210
views
CSRF verification failed. Request aborted. in django rest framework
halo
i'm working on a project, using drf, but i'm getting CSRF verification failed. Request aborted at first everything was working, but now when i test my api i keep keep getting,CSRF verification ...
0
votes
1
answer
2k
views
Delete expired tokens from database (Django + JWT)
Currently I am using JWT (rest_framework_simplejwt) with Django Rest Framework.
The database table containing tokens got bigger and bigger.
Is there any way to delete all expired access tokens from ...
0
votes
1
answer
896
views
DJANGO REST web login not working with JWT if permission set to IsAuthenticated
The rest framework has its default web-based API-authentication
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
However, once JWT authentication is added and the ...
0
votes
1
answer
1k
views
"Method \"GET\" not allowed." Django
my views.py file:
from rest_framework.views import APIView
from rest_framework.response import Response
from .serializers import UserSerializer
class TestView(APIView):
def get(self, request, ...
1
vote
3
answers
3k
views
How to add custom claim in django rest_framework_simple_jwt?
Their official doc only shows implementation for class based views.
How to get this done for a function, ie. Refreshtoken.for_user()?
from rest_framework_simplejwt.tokens import RefreshToken
def ...
1
vote
1
answer
2k
views
Django rest framework jwt {"detail": "You do not have permission to perform this action."}
I am trying to make a request using django-rest-framework and django-rest-framework-jwt but The response that I get detail": "You do not have permission to perform this action."
views....
0
votes
1
answer
2k
views
DRF simplejwt do not updating the access token
I'm using simpleJWT with Django restframework and i get this problem when i tried to refresh the access token, i post http request sending the refresh token to the refresh endpoint, it suppose to get ...
2
votes
1
answer
2k
views
how to login user either email or username in Django rest framework(JWT Token)
I'm using:
Django==3.2.9
djangorestframework==3.12.4
djangorestframework-simplejwt==5.0.0
I want to make a login system that takes either username or email and password as a parameter from a user. ...
1
vote
1
answer
346
views
limiting requests and authenticating the user in rest api
I have a machine learning model which I have converted as a Rest API using Django rest framework. Now I want to distribute the API to users but how can I authenticate and limit the requests by the ...
0
votes
1
answer
1k
views
How can I set JWT at the Frontend with bootstrap html not with react whilst the API is created with Django?
Recently I am studying and building API with Django. I successfully set up the API of authentication system with Django API.
I am curious to know that is there any solution to add this JWT with ...
1
vote
1
answer
3k
views
"detail": "Authentication credentials were not provided." Django-rest-frameweork and React
I'm trying to create Club object via React form but I get those 2 errors:
{"detail": "Authentication credentials were not provided."} and 401 Unauthorized. Obviously there is ...
0
votes
1
answer
625
views
ImportError: Could not import 'users.authenticate.jwt_response_payload_handler' for API setting
Set custom return error when using rest framework jwt token verification,ImportError: Could not import 'users.authenticate.jwt_response_payload_handler' for API setting 'JWT_RESPONSE_PAYLOAD_HANDLER'.
...
1
vote
0
answers
164
views
Getting "Authentication credentials were not provided" error when I don't want to require authentication
I have a project with JWT authentication in Django Rest Framework. Usually I require user to be authenticated but in the case of GET action (both list and retrieve) I would like everyone to be able to ...
0
votes
1
answer
2k
views
How to extract payload from a jwt Expired Token
I have made a view where I send a Refresh Token to email for activation account purpose. If token is valid everything works fine. The problem is when jwt token expire, I want to be able in backend to ...
0
votes
0
answers
46
views
I need to create an authentication for a distributor using jwt
I need to create an authentication for a distributor using jwt. However I'm only able to create the authentication token for the superuser. Could someone help me create a way to authenticate the ...
0
votes
1
answer
2k
views
How to get access token and refresh token ( rest_framework_jwt ) in a single API in Django
I need to get access token and refresh token in a single API, Currently I have 2 API's for both access and refresh tokens
url(r'^token-auth', view.ObtainJWTView.as_view(), name='token-auth'),
url(r'^...
0
votes
1
answer
1k
views
Django Rest-framework, JWT authentication
I'm newbie in Django Restframework. I use JWT to make login, register API, everythings worked well, I want to GET a user information with authenticated (tokens). This is my code for UserViewSet
class ...
0
votes
1
answer
261
views
Why am I getting 'ImageFieldFile' object has no attribute 'pk' when I login?
I am building a backend authentication in Django-Rest_framework using django-rest-auth and REST framework JWT Auth and when I login I keep getting this error. What am I doing wrong?
AttributeError at /...
2
votes
0
answers
400
views
Caching authentication result in django-rest-framework-jwt
I`m using Auth0 authentification in a webapp / django-server combination. Auth0 is not the fastest auth framework, it always takes 200ms to authenticate. My webapp sends a lot of requests to the ...
1
vote
1
answer
4k
views
how to validate access token and redirect user if expired to refreshtoen view in simple jwt authentication with django rest framework
How can i redirect user to obtain new access token in refresh token view if access token is expired ?
i implemented cookie based authentication with simple jwt library in django rest framework.
...
1
vote
1
answer
855
views
Changing the default user while using REST framework JWT
I have a proxied user model:
class TheDude(User):
class Meta:
proxy = True
And I'm using the Django REST framework JWT to do JWT auth in the REST API.
I'd like to get the user object from ...
1
vote
0
answers
517
views
return value.utcoffset() is not None AttributeError: 'datetime.date' object has no attribute 'utcoffset'
Pardon me but I am a bit new to Django,
Django does not even tell me the field having issues
I keep getting an error I don't understand
How do I know the field having issues?
When I try to fetch a ...
0
votes
1
answer
149
views
How to proccess token?
I have a question.
In my project, after a user loges in my app generates an access token and then put it on cookies.
This access token contains information like user rights and some other details ...
3
votes
3
answers
9k
views
"detail": "Authentication credentials were not provided." for general views
I have created a custom user model and apply Djoser authentication and jwt. But after this when I tried to get request for products views, I get this error:
"detail": "Authentication ...
0
votes
1
answer
4k
views
Could not import 'rest_framework_simplejwt.auth.JWTAuthentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'
I am trying to make REST APIs using Django. I have installed djangorestframework & djangorestframework-simplejwt using pip
pip install djangorestframework
pip install djangorestframework-simplejwt
...
0
votes
0
answers
315
views
Is there any minimum key length is required for JWT_PUBLIC_KEY ? getting error Could not deserialize key data
i have used restframework_jwt with RS256 algorithm, and successfully created access token. But i am getting a error "Could not deserialize key data." when try to use this token as ...
1
vote
1
answer
414
views
CSRF cookies not set - React, JWT, Django
I'm rather confused regarding the following error: "Forbidden (CSRF cookie not set.)". This error is received during attempting to logout, login, signup.
The problem is similar to this post ...
0
votes
0
answers
2k
views
"Missing filename. Request should include a Content-Disposition header with a filename parameter." Error? Problem with django-simplejwt
I am trying to work with djangorestframework-simplejwt and trying to follow this tutorial:
https://www.jetbrains.com/pycharm/guide/tutorials/django-aws/rest-api-jwt/
Currently I'm at this point where ...
1
vote
1
answer
2k
views
JWT: How do I implement my custom error message on password or username is wrong Django REST
I want to implement my own custome error message when user types wrong password in Django Rest JWT authentiction as of now default error message is
"detail": "No active account found ...