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: """