Skip to content
This repository was archived by the owner on Sep 29, 2023. It is now read-only.

Commit 914e83e

Browse files
committed
Make it compatible with PyJWT 1 & 2; also declare upper bound for requests and python-dateutil
1 parent 01f6fad commit 914e83e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

adal/self_signed_jwt.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ def _sign_jwt(header, payload, certificate):
5757
return encoded_jwt
5858

5959
def _encode_jwt(payload, certificate, header):
60-
return jwt.encode(payload, certificate, algorithm='RS256', headers=header).decode()
60+
encoded = jwt.encode(payload, certificate, algorithm='RS256', headers=header)
61+
try:
62+
return encoded.decode() # PyJWT 1.x returns bytes; historically we convert it to string
63+
except AttributeError:
64+
return encoded # PyJWT 2 will return string
6165

6266
def _raise_on_invalid_jwt_signature(encoded_jwt):
6367
segments = encoded_jwt.split('.')

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@
7676
],
7777
packages=['adal'],
7878
install_requires=[
79-
'PyJWT>=1.0.0',
80-
'requests>=2.0.0',
81-
'python-dateutil>=2.1.0',
79+
'PyJWT>=1.0.0,<3',
80+
'requests>=2.0.0,<3',
81+
'python-dateutil>=2.1.0,<3',
8282
'cryptography>=1.1.0'
8383
]
8484
)

0 commit comments

Comments
 (0)