flask-api-tutorial
flask-api-tutorial copied to clipboard
PyJWT encode return type has changed
As of version 2.0, the return type for jwt.encode is string instead of byte string, causing encode and decode tests to fail.
After reading this I've added these 3 lines to the end of encode_access_token in models.user.py
token = jwt.encode(payload, key, algorithm="HS256")
if isinstance(token, str):
token = token.encode("UTF-8")
which resolved this issue for me. Perhaps it has introduced new issues, hope not!