TypeError: initializer for ctype 'char[]' must be a bytes or list or tuple, not str
0xTheProDev opened this issue · 2 comments
0xTheProDev commented
Getting this error right now.
Using:
jwtObject = JWT()
with open('private_key', 'rb') as fh:
salt = jwk_from_pem(fh.read())
jwt = jwtObject.encode(user, salt, 'RS256')
with open('public_key', 'r') as fh:
salt = jwk_from_pem(fh.read())
test = jwtObject.decode(jwt, salt)
print(test)
yosida95 commented
jwk_from_pem
only accepts the bytes
type. But you passed content of public_key
in the str
type.
yosida95 commented
This is due to that you open public_key
using text mode. You should open it in binary mode. Please refer to https://docs.python.org/3.5/library/functions.html#open.