Skip to content

Commit

Permalink
Merge pull request #352 from fbeutel/urlsafe_b64decode
Browse files Browse the repository at this point in the history
Use urlsafe_b64decode to properly handle URL-encoded JWTs
  • Loading branch information
J0 authored Oct 23, 2023
2 parents 8da1032 + 0034af1 commit 7541ade
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gotrue/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from base64 import b64decode
from base64 import urlsafe_b64decode
from json import loads
from typing import Any, Dict, Type, TypeVar, Union, cast

Expand Down Expand Up @@ -123,4 +123,4 @@ def decode_jwt_payload(token: str) -> Any:
# Addding padding otherwise the following error happens:
# binascii.Error: Incorrect padding
base64UrlWithPadding = base64Url + "=" * (-len(base64Url) % 4)
return loads(b64decode(base64UrlWithPadding).decode("utf-8"))
return loads(urlsafe_b64decode(base64UrlWithPadding).decode("utf-8"))

0 comments on commit 7541ade

Please sign in to comment.