Skip to content

Commit

Permalink
Merge pull request #4 from soneji/patch-1
Browse files Browse the repository at this point in the history
Fix to add support for PyJWT>=2.0.0a1 and keep support for PyJWT<=1.7.1
  • Loading branch information
raimonte authored Feb 25, 2021
2 parents 93119b2 + 8723801 commit 23c431d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/jwt_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@ def make_jwt_payload(api_key: str, token_exp_delta: int) -> dict:

def generate_jwt_token(payload: dict, api_secret: str) -> str:
encoded = jwt.encode(payload, api_secret, algorithm='HS256')
return encoded.decode()
if isinstance(encoded, bytes):
# For PyJWT <= 1.7.1
return encoded.decode()
# For PyJWT >= 2.0.0a1
return encoded

0 comments on commit 23c431d

Please sign in to comment.