From f1d8cbaab5cce1defe067b698a003f234731e95d Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 1 Nov 2023 15:03:19 +0000 Subject: [PATCH] fix: add flow_type to client options --- supabase/client.py | 1 + supabase/lib/auth_client.py | 9 ++++++++- supabase/lib/client_options.py | 7 ++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/supabase/client.py b/supabase/client.py index 98ea8bd1..9df5aca3 100644 --- a/supabase/client.py +++ b/supabase/client.py @@ -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 diff --git a/supabase/lib/auth_client.py b/supabase/lib/auth_client.py index 10800a52..b86cfeef 100644 --- a/supabase/lib/auth_client.py +++ b/supabase/lib/auth_client.py @@ -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 @@ -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: @@ -38,4 +44,5 @@ def __init__( persist_session=persist_session, storage=storage, http_client=http_client, + flow_type=flow_type, ) diff --git a/supabase/lib/client_options.py b/supabase/lib/client_options.py index 638bc636..0c55a159 100644 --- a/supabase/lib/client_options.py +++ b/supabase/lib/client_options.py @@ -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 @@ -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, @@ -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() @@ -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