Skip to content

jws.verify returns byte, not string as documented #184

Open
@raphet

Description

@raphet

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

str: The str representation of the payload, assuming the signature is valid.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions