From 87b70716c1a76ca6ee11b2738ab146f07d746b53 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 24 Aug 2021 22:55:42 +0200 Subject: [PATCH] Logic for supporting JWT tokens both as bytes and strings [closes #197] --- platypush/user/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platypush/user/__init__.py b/platypush/user/__init__.py index f1f8a3612..c519799bf 100644 --- a/platypush/user/__init__.py +++ b/platypush/user/__init__.py @@ -191,7 +191,10 @@ class UserManager: 'expires_at': expires_at.timestamp() if expires_at else None, } - return jwt.encode(payload, priv_key, algorithm='RS256').decode() + token = jwt.encode(payload, priv_key, algorithm='RS256') + if isinstance(token, bytes): + token = token.decode() + return token @staticmethod def validate_jwt_token(token: str) -> Dict[str, str]: