Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 59b90d5

Browse files
committed
feat: Add exception to handle API errors on signout
1 parent 5155312 commit 59b90d5

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

gotrue/_async/gotrue_client.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
STORAGE_KEY,
1717
)
1818
from ..errors import (
19+
AuthApiError,
1920
AuthImplicitGrantRedirectError,
2021
AuthInvalidCredentialsError,
2122
AuthRetryableError,
@@ -483,10 +484,15 @@ async def sign_out(self) -> None:
483484
There is no way to revoke a user's access token jwt until it expires.
484485
It is recommended to set a shorter expiry on the jwt for this reason.
485486
"""
486-
session = await self.get_session()
487-
access_token = session.access_token if session else None
488-
if access_token:
489-
await self.admin.sign_out(access_token)
487+
try:
488+
session = await self.get_session()
489+
access_token = session.access_token if session else None
490+
if access_token:
491+
await self.admin.sign_out(access_token)
492+
except AuthApiError:
493+
pass
494+
except Exception:
495+
raise
490496
await self._remove_session()
491497
self._notify_all_subscribers("SIGNED_OUT", None)
492498

gotrue/_sync/gotrue_client.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
STORAGE_KEY,
1717
)
1818
from ..errors import (
19+
AuthApiError,
1920
AuthImplicitGrantRedirectError,
2021
AuthInvalidCredentialsError,
2122
AuthRetryableError,
@@ -481,10 +482,15 @@ def sign_out(self) -> None:
481482
There is no way to revoke a user's access token jwt until it expires.
482483
It is recommended to set a shorter expiry on the jwt for this reason.
483484
"""
484-
session = self.get_session()
485-
access_token = session.access_token if session else None
486-
if access_token:
487-
self.admin.sign_out(access_token)
485+
try:
486+
session = self.get_session()
487+
access_token = session.access_token if session else None
488+
if access_token:
489+
self.admin.sign_out(access_token)
490+
except AuthApiError:
491+
pass
492+
except Exception:
493+
raise
488494
self._remove_session()
489495
self._notify_all_subscribers("SIGNED_OUT", None)
490496

0 commit comments

Comments
 (0)