From dcc011aca7c699221102b7877509f56db9288854 Mon Sep 17 00:00:00 2001 From: Mick Chanthaseth Date: Sat, 23 Oct 2021 17:46:50 -0700 Subject: [PATCH] return token in _create_token if type is string; otherwise, decode --- fastapi_jwt_auth/auth_jwt.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fastapi_jwt_auth/auth_jwt.py b/fastapi_jwt_auth/auth_jwt.py index 4110bdb..6b76135 100644 --- a/fastapi_jwt_auth/auth_jwt.py +++ b/fastapi_jwt_auth/auth_jwt.py @@ -186,12 +186,14 @@ def _create_token( except Exception: raise - return jwt.encode( + token = jwt.encode( {**reserved_claims, **custom_claims, **user_claims}, secret_key, algorithm=algorithm, headers=headers - ).decode('utf-8') + ) + + return token if type(token) == str else token.decode('utf-8') def _has_token_in_denylist_callback(self) -> bool: """