flask-jwt-simple icon indicating copy to clipboard operation
flask-jwt-simple copied to clipboard

Incompatible with PyJWT 2.0

Open okngneer opened this issue 4 years ago • 4 comments

PyJWT changed jwt.encode to return str instead of bytes breaking Flask-JWT-Simple as seen below.

    def _create_jwt(self, identity):
        jwt_data = self._get_jwt_data(identity)
        secret = config.encode_key
        algorithm = config.algorithm
>       return jwt.encode(jwt_data, secret, algorithm).decode('utf-8')
E       AttributeError: 'str' object has no attribute 'decode'

.venv/lib/python3.8/site-packages/flask_jwt_simple/jwt_manager.py:175: AttributeError

okngneer avatar Jan 31 '21 21:01 okngneer

Hello @vimalloc

Can you tell if this library is still maintained? So that we know if we should wait for the dependency bump to be handled or switch to another solution?

Thanks again

Colin-b avatar Feb 09 '21 16:02 Colin-b

@Colin-b Thanks for pinging me, I missed this ticket when it was first opened.

My current plan is to depreciate this extension when I finish up the flask-jwt-extended 4.0.0 release. This library has seen very little usage, and the primary benefit of it over flask-jwt-extended is that you have more control over the claims in your JWTs, which will be largely rectified in the 4.0.0 release. The code for 4.0.0 is done, I just need to finish up documentation so it shouldn't be much longer now.

In the mean time you can pin pyjwt locally to 1.7.1 for your local project to resolve the issue. Or if anyone wants to keep this project alive I would be happy to transfer ownership over to them.

Cheers.

vimalloc avatar Feb 09 '21 18:02 vimalloc

Thx for the prompt response, well I am glad to hear that there is another module. I will certainly assess and do the switch asap. Indeed dependencies were pinned obviously :)

Colin-b avatar Feb 09 '21 20:02 Colin-b

FYI, flask-jwt-extended 4.0 is released.

okngneer avatar Feb 17 '21 13:02 okngneer