Skip to content

Commit

Permalink
fix: add flow_type to client options (#610)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Smith authored Nov 1, 2023
2 parents ca79bbd + f1d8cba commit 344850d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions supabase/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def _init_supabase_auth_client(
persist_session=client_options.persist_session,
storage=client_options.storage,
headers=client_options.headers,
flow_type=client_options.flow_type,
)

@staticmethod
Expand Down
9 changes: 8 additions & 1 deletion supabase/lib/auth_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from typing import Dict, Optional

from gotrue import SyncGoTrueClient, SyncMemoryStorage, SyncSupportedStorage
from gotrue import (
AuthFlowType,
SyncGoTrueClient,
SyncMemoryStorage,
SyncSupportedStorage,
)

# TODO - export this from GoTrue-py in next release
from httpx import Client as BaseClient
Expand All @@ -24,6 +29,7 @@ def __init__(
persist_session: bool = True,
storage: SyncSupportedStorage = SyncMemoryStorage(),
http_client: Optional[SyncClient] = None,
flow_type: AuthFlowType = "implicit"
):
"""Instantiate SupabaseAuthClient instance."""
if headers is None:
Expand All @@ -38,4 +44,5 @@ def __init__(
persist_session=persist_session,
storage=storage,
http_client=http_client,
flow_type=flow_type,
)
7 changes: 6 additions & 1 deletion supabase/lib/client_options.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dataclasses import dataclass, field
from typing import Any, Dict, Optional, Union

from gotrue import SyncMemoryStorage, SyncSupportedStorage
from gotrue import AuthFlowType, SyncMemoryStorage, SyncSupportedStorage
from httpx import Timeout
from postgrest.constants import DEFAULT_POSTGREST_CLIENT_TIMEOUT
from storage3.constants import DEFAULT_TIMEOUT as DEFAULT_STORAGE_CLIENT_TIMEOUT
Expand Down Expand Up @@ -42,6 +42,9 @@ class ClientOptions:
storage_client_timeout: Union[int, float, Timeout] = DEFAULT_STORAGE_CLIENT_TIMEOUT
"""Timeout passed to the SyncStorageClient instance"""

flow_type: AuthFlowType = "implicit"
"""flow type to use for authentication"""

def replace(
self,
schema: Optional[str] = None,
Expand All @@ -56,6 +59,7 @@ def replace(
storage_client_timeout: Union[
int, float, Timeout
] = DEFAULT_STORAGE_CLIENT_TIMEOUT,
flow_type: Optional[AuthFlowType] = None,
) -> "ClientOptions":
"""Create a new SupabaseClientOptions with changes"""
client_options = ClientOptions()
Expand All @@ -73,4 +77,5 @@ def replace(
client_options.storage_client_timeout = (
storage_client_timeout or self.storage_client_timeout
)
client_options.flow_type = flow_type or self.flow_type
return client_options

0 comments on commit 344850d

Please sign in to comment.