Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add flow_type to client options #610

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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