python-jose
python-jose copied to clipboard
jws.verify returns byte, not string as documented
Problem jws.verify() returns byte, not string. It's wrong in your code and it's wrong in the documentation https://python-jose.readthedocs.io/en/latest/jwk/index.html https://github.com/mpdavis/python-jose/blob/5ec9f48c1babcbfa62d433b29e55db8888c315ec/jose/jws.py#L65
Actual result
>>> token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhIjoiYiJ9.jiMyrsmD8AoHWeQgmxZ5yq8z0lXS67_QGs52AzC8Ru8'
>>> jws.verify(token, 'secret', algorithms='HS256')
b'{"a":"b"}'
Expected result
{"a":"b"}
Fix
>>> token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhIjoiYiJ9.jiMyrsmD8AoHWeQgmxZ5yq8z0lXS67_QGs52AzC8Ru8'
>>> jws.verify(token, 'secret', algorithms='HS256').decode('utf-8)
'{"a":"b"}'
This is the second defect in your documentation I find.
This is the second defect in your documentation I find.
I don't understand the point you are trying to make. All software contains bugs, and I'm sure there are more defects in our documentation.
Since this is such a simple fix, I'll wait for your pull request that fixes the documentation. Thanks! 😃