Python: linux support (bug with json jwt decoding)

This commit is contained in:
Andrey Yumatov
2022-02-01 15:19:15 +03:00
parent 5bbc4c6232
commit a07edeb5de

View File

@ -26,6 +26,7 @@
import config
import jwt
import platform
# check if a secret key to generate token exists or not
def isEnabled():
@ -33,7 +34,10 @@ def isEnabled():
# encode a payload object into a token using a secret key and decodes it into the utf-8 format
def encode(payload):
return jwt.encode(payload, config.DOC_SERV_JWT_SECRET, algorithm='HS256').decode('utf-8')
jwtEncode = jwt.encode(payload, config.DOC_SERV_JWT_SECRET, algorithm='HS256')
if platform.system() != "Linux": return jwtEncode.decode('utf-8')
return jwtEncode
# decode a token into a payload object using a secret key
def decode(string):