Skip to content

Commit d3735ad

Browse files
kit494wayrayluo
authored andcommitted
Use urlsafe_b64decode instead of b64decode (#84)
* Use urlsafe_b64decode instead of b64decode * Fix decoding error on Python 2.7
1 parent ea7fe4c commit d3735ad

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

msal/oauth2cli/oidc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
def base64decode(raw):
99
"""A helper can handle a padding-less raw input"""
1010
raw += '=' * (-len(raw) % 4) # https://stackoverflow.com/a/32517907/728675
11-
return base64.b64decode(raw).decode("utf-8")
11+
# On Python 2.7, argument of urlsafe_b64decode must be str, not unicode.
12+
# This is not required on Python 3.
13+
raw = str(raw)
14+
return base64.urlsafe_b64decode(raw).decode("utf-8")
1215

1316

1417
def decode_id_token(id_token, client_id=None, issuer=None, nonce=None, now=None):

0 commit comments

Comments
 (0)