I\'m using django-rest-framework-simplejwt and was wondering if it\'s possible to return a token after registering a user?
This post has a solution for another jwt packa
another possible solution is:
in your view
from rest_framework_simplejwt.serializers import TokenObtainPairSerializer
from rest_framework_simplejwt.tokens import AccessToken, RefreshToken
@login_required
def index(request):
tokenr = TokenObtainPairSerializer().get_token(request.user)
tokena = AccessToken().for_user(request.user)
return render(request,'myview/index.html', {"refresh" : str(tokenr),"access" : str(tokena)} )
I used @login_required just to be sure we have a request.user authenticated, but you could pass a dict instead