from django.conf import settings
from django.http.response import HttpResponseBadRequest, JsonResponse
from django.utils import timezone
from rest_framework.decorators import api_view, permission_classes
from rest_framework.permissions import IsAuthenticated
@permission_classes((IsAuthenticated,))
chat_id = request.data.get('chat_id')
return HttpResponseBadRequest()
iat = int(now.timestamp())
expires = int((now + datetime.timedelta(minutes=1)).timestamp()) # JWT is valid for 1 minute
'name': user.get_full_name(),
'picture': 'https://example.com/avatar.jpg',
token = jwt.encode(payload, settings.CHAT_CLIENT_AUTH_PRIVATE_KEY, algorithm='RS256').decode('utf-8')
return JsonResponse({'token': token}, status=200)