Skip to content

Commit

Permalink
Merge pull request #254 from supabase-community/j0/patch_padding_for_…
Browse files Browse the repository at this point in the history
…base64

fix: patch padding for base64
  • Loading branch information
J0 authored Mar 24, 2023
2 parents 5d075d2 + a37afe3 commit f77663a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gotrue/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,7 @@ def decode_jwt_payload(token: str) -> Any:
if len(parts) != 3:
raise ValueError("JWT is not valid: not a JWT structure")
base64Url = parts[1]
return loads(b64decode(base64Url).decode("utf-8"))
# Addding padding otherwise the following error happens:
# binascii.Error: Incorrect padding
base64UrlWithPadding = base64Url + "=" * (-len(base64Url) % 4)
return loads(b64decode(base64UrlWithPadding).decode("utf-8"))

0 comments on commit f77663a

Please sign in to comment.