Skip to content

Commit 344850d

Browse files
author
Andrew Smith
authored
fix: add flow_type to client options (#610)
2 parents ca79bbd + f1d8cba commit 344850d

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

supabase/client.py

+1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ def _init_supabase_auth_client(
210210
persist_session=client_options.persist_session,
211211
storage=client_options.storage,
212212
headers=client_options.headers,
213+
flow_type=client_options.flow_type,
213214
)
214215

215216
@staticmethod

supabase/lib/auth_client.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
from typing import Dict, Optional
22

3-
from gotrue import SyncGoTrueClient, SyncMemoryStorage, SyncSupportedStorage
3+
from gotrue import (
4+
AuthFlowType,
5+
SyncGoTrueClient,
6+
SyncMemoryStorage,
7+
SyncSupportedStorage,
8+
)
49

510
# TODO - export this from GoTrue-py in next release
611
from httpx import Client as BaseClient
@@ -24,6 +29,7 @@ def __init__(
2429
persist_session: bool = True,
2530
storage: SyncSupportedStorage = SyncMemoryStorage(),
2631
http_client: Optional[SyncClient] = None,
32+
flow_type: AuthFlowType = "implicit"
2733
):
2834
"""Instantiate SupabaseAuthClient instance."""
2935
if headers is None:
@@ -38,4 +44,5 @@ def __init__(
3844
persist_session=persist_session,
3945
storage=storage,
4046
http_client=http_client,
47+
flow_type=flow_type,
4148
)

supabase/lib/client_options.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from dataclasses import dataclass, field
22
from typing import Any, Dict, Optional, Union
33

4-
from gotrue import SyncMemoryStorage, SyncSupportedStorage
4+
from gotrue import AuthFlowType, SyncMemoryStorage, SyncSupportedStorage
55
from httpx import Timeout
66
from postgrest.constants import DEFAULT_POSTGREST_CLIENT_TIMEOUT
77
from storage3.constants import DEFAULT_TIMEOUT as DEFAULT_STORAGE_CLIENT_TIMEOUT
@@ -42,6 +42,9 @@ class ClientOptions:
4242
storage_client_timeout: Union[int, float, Timeout] = DEFAULT_STORAGE_CLIENT_TIMEOUT
4343
"""Timeout passed to the SyncStorageClient instance"""
4444

45+
flow_type: AuthFlowType = "implicit"
46+
"""flow type to use for authentication"""
47+
4548
def replace(
4649
self,
4750
schema: Optional[str] = None,
@@ -56,6 +59,7 @@ def replace(
5659
storage_client_timeout: Union[
5760
int, float, Timeout
5861
] = DEFAULT_STORAGE_CLIENT_TIMEOUT,
62+
flow_type: Optional[AuthFlowType] = None,
5963
) -> "ClientOptions":
6064
"""Create a new SupabaseClientOptions with changes"""
6165
client_options = ClientOptions()
@@ -73,4 +77,5 @@ def replace(
7377
client_options.storage_client_timeout = (
7478
storage_client_timeout or self.storage_client_timeout
7579
)
80+
client_options.flow_type = flow_type or self.flow_type
7681
return client_options

0 commit comments

Comments
 (0)