From 0063555306c9a239fc3257f6aa2c0ab87746cfa3 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Fri, 30 Aug 2024 00:06:03 +0000 Subject: [PATCH] feat: add reauthenticate method --- supabase_auth/_async/gotrue_client.py | 12 ++++++++++++ supabase_auth/_sync/gotrue_client.py | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/supabase_auth/_async/gotrue_client.py b/supabase_auth/_async/gotrue_client.py index 739abaa5..35536993 100644 --- a/supabase_auth/_async/gotrue_client.py +++ b/supabase_auth/_async/gotrue_client.py @@ -541,6 +541,18 @@ async def verify_otp(self, params: VerifyOtpParams) -> AuthResponse: self._notify_all_subscribers("SIGNED_IN", response.session) return response + async def reauthenticate(self) -> AuthResponse: + session = await self.get_session() + if not session: + raise AuthSessionMissingError() + + return await self._request( + "GET", + "reauthenticate", + jwt=session.access_token, + xform=parse_auth_response, + ) + async def get_session(self) -> Union[Session, None]: """ Returns the session, refreshing it if necessary. diff --git a/supabase_auth/_sync/gotrue_client.py b/supabase_auth/_sync/gotrue_client.py index dc52c85d..cd26728b 100644 --- a/supabase_auth/_sync/gotrue_client.py +++ b/supabase_auth/_sync/gotrue_client.py @@ -535,6 +535,18 @@ def verify_otp(self, params: VerifyOtpParams) -> AuthResponse: self._notify_all_subscribers("SIGNED_IN", response.session) return response + def reauthenticate(self) -> AuthResponse: + session = self.get_session() + if not session: + raise AuthSessionMissingError() + + return self._request( + "GET", + "reauthenticate", + jwt=session.access_token, + xform=parse_auth_response, + ) + def get_session(self) -> Union[Session, None]: """ Returns the session, refreshing it if necessary.