According to pyjwt docs it can be either datetime object or number (unix
epoch)

https://pyjwt.readthedocs.io/en/latest/usage.html#expiration-time-claim-exp


3.11.2017 9.37 "James Schneider" <jrschneide...@gmail.com> kirjoitti:

>
>
> On Oct 31, 2017 4:36 AM, "Rakhee Menon" <rakhee.autos...@gmail.com> wrote:
>
>
>
> class Login(APIView):
>
>    def post(self, request, *args, **kwargs):
>        import ipdb;ipdb.set_trace()
>        username = request.POST.get('username')
>        password = request.POST.get('password')
>        user = Person.objects.get(username=username, password=password)
> #        user = user[0]
>        #import ipdb;ipdb.set_trace()
>        if user:
>            payload = {
>                'id': user.pk,
>                'username': user.username,
>                'staff': user.email,
>                'exp': datetime.utcnow()
>
>
> I think that datetime.utcnow() returns a datetime object, not a string,
> and I don't think it can be serialized directly. You should try converting
> that object to a string in the right format. As a test, substitute a static
> string containing a date and time in whatever format you need. I'm not in
> front of an interpreter so I can't test, but this seems to back up my
> theory:
>
> https://code-maven.com/serialize-datetime-object-as-json-in-python
>
> -James
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CA%2Be%2BciUy4yT%2BMsjAdH9pJXfhC4kBkSW832dbuZjq
> qLKCaKn5fQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CA%2Be%2BciUy4yT%2BMsjAdH9pJXfhC4kBkSW832dbuZjqqLKCaKn5fQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91od3H3XYL5opHAg6tuSjTXwRtZ3fO7mfD0%3DAH_vtOYz0jA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to