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

Commit f3d35c7

Browse files
committed
Add Anonymous login
1 parent 98006ed commit f3d35c7

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

supabase_auth/_sync/gotrue_client.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
Subscription,
7070
UserAttributes,
7171
UserResponse,
72-
VerifyOtpParams,
72+
VerifyOtpParams, SignInAnonymouslyCredentials,
7373
)
7474
from .gotrue_admin_api import SyncGoTrueAdminAPI
7575
from .gotrue_base_api import SyncGoTrueBaseAPI
@@ -337,6 +337,29 @@ def sign_in_with_oauth(
337337
url = self._get_url_for_provider(provider, params)
338338
return OAuthResponse(provider=provider, url=url)
339339

340+
def sign_in_anonymously(self, credentials: Union[SignInAnonymouslyCredentials]) -> AuthResponse:
341+
"""
342+
Creates a new anonymous user.
343+
"""
344+
self._remove_session()
345+
options = credentials.get("options", {})
346+
data = options.get("data") or {}
347+
captcha_token = options.get("captcha_token")
348+
response = self._request(
349+
"POST",
350+
"signup",
351+
body={
352+
"data": data,
353+
"gotrue_meta_security": {
354+
"captcha_token": captcha_token,
355+
},
356+
}
357+
)
358+
if response.session:
359+
self._save_session(response.session)
360+
self._notify_all_subscribers("SIGNED_IN", response.session)
361+
return response
362+
340363
def link_identity(self, credentials):
341364
provider = credentials.get("provider")
342365
options = credentials.get("options", {})

supabase_auth/types.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,15 @@ class SignInWithSSOOptions(TypedDict):
348348
skip_http_redirect: NotRequired[bool]
349349

350350

351+
class SignInAnonymouslyCredentials(TypedDict):
352+
options: NotRequired[SignInAnonymouslySSOOptions]
353+
354+
355+
class SignInAnonymouslySSOOptions(TypedDict):
356+
data: NotRequired[Any]
357+
captcha_token: NotRequired[str]
358+
359+
351360
class VerifyOtpParamsOptions(TypedDict):
352361
redirect_to: NotRequired[str]
353362
captcha_token: NotRequired[str]

0 commit comments

Comments
 (0)