Skip to content

If key is bytes, encode works, decode fails #126

Description

@friedcell
>>> key = b'key'
>>> token = jwt.encode({'key': 'value'}, key, algorithm='HS256')
>>> jwt.decode(token, key, algorithms=['HS256'])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lib/python3.5/site-packages/jose/jwt.py", line 134, in decode
payload = jws.verify(token, key, algorithms, verify=verify_signature)
File "/lib/python3.5/site-packages/jose/jws.py", line 75, in verify
_verify_signature(signing_input, header, signature, key, algorithms)
File "/lib/python3.5/site-packages/jose/jws.py", line 260, in _verify_signature
keys = _get_keys(key)
File "/lib/python3.5/site-packages/jose/jws.py", line 227, in _get_keys
if 'keys' in key:
TypeError: a bytes-like object is required, not 'str'

I think either both should work or both should fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions