From 8ff54ae9d29b7267cbab796f613e4ce07a7a413d Mon Sep 17 00:00:00 2001 From: luislechugaruiz Date: Tue, 3 Sep 2024 19:09:17 +0200 Subject: [PATCH] Await for realtime set auth on auth event --- supabase/_async/client.py | 6 +++--- supabase/_sync/client.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/supabase/_async/client.py b/supabase/_async/client.py index 48ba994b..38ad46fe 100644 --- a/supabase/_async/client.py +++ b/supabase/_async/client.py @@ -284,7 +284,7 @@ def _get_auth_headers( "Authorization": authorization, } - def _listen_to_auth_events( + async def _listen_to_auth_events( self, event: AuthChangeEvent, session: Union[Session, None] ): access_token = self.supabase_key @@ -297,8 +297,8 @@ def _listen_to_auth_events( self.options.headers["Authorization"] = self._create_auth_header(access_token) - # set_auth is a coroutine, how to handle this? - self.realtime.set_auth(access_token) + # Await for the realtime client to set the auth token + await self.realtime.set_auth(access_token) async def create_client( diff --git a/supabase/_sync/client.py b/supabase/_sync/client.py index 4ec1ee5e..03882494 100644 --- a/supabase/_sync/client.py +++ b/supabase/_sync/client.py @@ -284,7 +284,7 @@ def _get_auth_headers( "Authorization": authorization, } - def _listen_to_auth_events( + async def _listen_to_auth_events( self, event: AuthChangeEvent, session: Union[Session, None] ): access_token = self.supabase_key @@ -297,8 +297,8 @@ def _listen_to_auth_events( self.options.headers["Authorization"] = self._create_auth_header(access_token) - # set_auth is a coroutine, how to handle this? - self.realtime.set_auth(access_token) + # Await for the realtime client to set the auth token + await self.realtime.set_auth(access_token) def create_client(