Skip to content

Commit c46c3a5

Browse files
fix: update auth client options
1 parent 323d29c commit c46c3a5

File tree

4 files changed

+22
-31
lines changed

4 files changed

+22
-31
lines changed

supabase/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def _init_supabase_auth_client(
178178
url=auth_url,
179179
auto_refresh_token=client_options.auto_refresh_token,
180180
persist_session=client_options.persist_session,
181-
local_storage=client_options.local_storage,
181+
storage=client_options.storage,
182182
headers=client_options.headers,
183183
)
184184

supabase/lib/auth_client.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
from typing import Dict, Optional
1+
from typing import Dict, Union
22

3-
from gotrue import (
4-
CookieOptions,
5-
SyncGoTrueAPI,
6-
SyncGoTrueClient,
7-
SyncMemoryStorage,
8-
SyncSupportedStorage,
9-
)
10-
from gotrue.constants import COOKIE_OPTIONS
3+
from gotrue import SyncGoTrueClient, SyncMemoryStorage, SyncSupportedStorage
114

125

136
class SupabaseAuthClient(SyncGoTrueClient):
@@ -18,22 +11,20 @@ def __init__(
1811
*,
1912
url: str,
2013
headers: Dict[str, str] = {},
14+
storage_key: Union[str, None] = None,
2115
auto_refresh_token: bool = True,
2216
persist_session: bool = True,
23-
local_storage: SyncSupportedStorage = SyncMemoryStorage(),
24-
cookie_options: CookieOptions = CookieOptions.parse_obj(COOKIE_OPTIONS),
25-
api: Optional[SyncGoTrueAPI] = None,
26-
replace_default_headers: bool = False,
17+
storage: SyncSupportedStorage = SyncMemoryStorage(),
18+
http_client: Union[SyncClient, None] = None,
2719
):
2820
"""Instantiate SupabaseAuthClient instance."""
2921
SyncGoTrueClient.__init__(
3022
self,
3123
url=url,
3224
headers=headers,
25+
storage_key=storage_key,
3326
auto_refresh_token=auto_refresh_token,
3427
persist_session=persist_session,
35-
local_storage=local_storage,
36-
cookie_options=cookie_options,
37-
api=api,
38-
replace_default_headers=replace_default_headers,
28+
storage=storage,
29+
http_client=http_client,
3930
)

supabase/lib/client_options.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ClientOptions:
2727
persist_session: bool = True
2828
"""Whether to persist a logged in session to storage."""
2929

30-
local_storage: SyncSupportedStorage = field(default_factory=SyncMemoryStorage)
30+
storage: SyncSupportedStorage = field(default_factory=SyncMemoryStorage)
3131
"""A storage provider. Used to store the logged in session."""
3232

3333
realtime: Optional[Dict[str, Any]] = None
@@ -45,7 +45,7 @@ def replace(
4545
headers: Optional[Dict[str, str]] = None,
4646
auto_refresh_token: Optional[bool] = None,
4747
persist_session: Optional[bool] = None,
48-
local_storage: Optional[SyncSupportedStorage] = None,
48+
storage: Optional[SyncSupportedStorage] = None,
4949
realtime: Optional[Dict[str, Any]] = None,
5050
fetch: Optional[Callable] = None,
5151
timeout: Union[int, float, Timeout] = DEFAULT_POSTGREST_CLIENT_TIMEOUT,
@@ -58,7 +58,7 @@ def replace(
5858
auto_refresh_token or self.auto_refresh_token
5959
)
6060
client_options.persist_session = persist_session or self.persist_session
61-
client_options.local_storage = local_storage or self.local_storage
61+
client_options.storage = storage or self.storage
6262
client_options.realtime = realtime or self.realtime
6363
client_options.fetch = fetch or self.fetch
6464
client_options.timeout = timeout or self.timeout

tests/test_client_options.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55

66
def test__client_options__replace__returns_updated_options():
7-
local_storage = SyncMemoryStorage()
8-
local_storage.set_item("key", "value")
7+
storage = SyncMemoryStorage()
8+
storage.set_item("key", "value")
99
options = ClientOptions(
1010
schema="schema",
1111
headers={"key": "value"},
1212
auto_refresh_token=False,
1313
persist_session=False,
14-
local_storage=local_storage,
14+
storage=storage,
1515
realtime={"key": "value"},
1616
)
1717

@@ -21,7 +21,7 @@ def test__client_options__replace__returns_updated_options():
2121
headers={"key": "value"},
2222
auto_refresh_token=False,
2323
persist_session=False,
24-
local_storage=local_storage,
24+
storage=storage,
2525
realtime={"key": "value"},
2626
)
2727

@@ -30,14 +30,14 @@ def test__client_options__replace__returns_updated_options():
3030

3131
def test__client_options__replace__updates_only_new_options():
3232
# Arrange
33-
local_storage = SyncMemoryStorage()
34-
local_storage.set_item("key", "value")
35-
options = ClientOptions(local_storage=local_storage)
33+
storage = SyncMemoryStorage()
34+
storage.set_item("key", "value")
35+
options = ClientOptions(storage=storage)
3636
new_options = options.replace()
3737

3838
# Act
39-
new_options.local_storage.set_item("key", "new_value")
39+
new_options.storage.set_item("key", "new_value")
4040

4141
# Assert
42-
assert options.local_storage.get_item("key") == "new_value"
43-
assert new_options.local_storage.get_item("key") == "new_value"
42+
assert options.storage.get_item("key") == "new_value"
43+
assert new_options.storage.get_item("key") == "new_value"

0 commit comments

Comments
 (0)