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

Commit 96c1bcf

Browse files
feat: Check if token is a JWT
1 parent 97d3c6c commit 96c1bcf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

postgrest/base_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from httpx import BasicAuth, Timeout
77

8-
from .utils import AsyncClient, SyncClient, is_http_url
8+
from .utils import AsyncClient, SyncClient, is_http_url, is_valid_jwt
99

1010

1111
class BasePostgrestClient(ABC):
@@ -58,6 +58,8 @@ def auth(
5858
Bearer token is preferred if both ones are provided.
5959
"""
6060
if token:
61+
if not is_valid_jwt(token):
62+
ValueError("token must be a valid JWT authorization token")
6163
self.session.headers["Authorization"] = f"Bearer {token}"
6264
elif username:
6365
self.session.auth = BasicAuth(username, password)

0 commit comments

Comments
 (0)