From 0034af1816b54c043079ef251df6ac2f76d5b41b Mon Sep 17 00:00:00 2001 From: fbeutel Date: Fri, 20 Oct 2023 17:59:41 +0200 Subject: [PATCH] Use urlsafe_b64decode to properly handle URL-encoded JWTs --- gotrue/helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gotrue/helpers.py b/gotrue/helpers.py index 79fa33c7..957218c7 100644 --- a/gotrue/helpers.py +++ b/gotrue/helpers.py @@ -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 @@ -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"))