djangorestframework-simplejwt: AttributeError: 'str' object has no attribute 'decode'.

Hey– I’m trying to get this package integrated and I’m getting something odd here when a jwt is being created. Is anyone else running into this issue? I’m on 4.4.0

AttributeError: ‘str’ object has no attribute ‘decode’.

  File "/.../.venv/lib/python3.7/site-packages/rest_framework_simplejwt/tokens.py", line 226, in for_user
    token=str(token),
  File "/.../.venv/lib/python3.7/site-packages/rest_framework_simplejwt/tokens.py", line 82, in __str__
    return token_backend.encode(self.payload)
  File "/.../.venv/lib/python3.7/site-packages/rest_framework_simplejwt/backends.py", line 43, in encode
    return token.decode('utf-8')
AttributeError: 'str' object has no attribute 'decode'

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 20 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Still having it on 4.6.0. Started a few hours ago, out of the blue.

Long live open source software.

On Dec 23, 2020, at 12:05 AM, chp notifications@github.com wrote:

Yeah, it fucked up a lot of things for us in a very bad timing; but that’s not at all affect any of my appreciation for your work. It’s a great library and I ❤️ your work.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

Yeah, it fucked up a lot of things for us in a very bad timing; but that’s not at all affect any of my appreciation for your work. It’s a great library and I ❤️ your work.

Alright apologies. I don’t understand what changed in PyJWT 2.0.0a1 to 2.0.0, but apparently it broke stuff… again (as noted in master branch). So reopening a different issue (it’s a duplicate) to mark for historical purposes. Find it at #346

#327 should come out in the next release (maybe a quick patch release).

Ah yes looks like I was on 2.0.0. I have downgraded to 1.7.1 for now.