This repository was archived by the owner on Sep 8, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 6969 Subscription,
7070 UserAttributes,
7171 UserResponse,
72- VerifyOtpParams,
72+ VerifyOtpParams, SignInAnonymouslyCredentials,
7373)
7474from .gotrue_admin_api import SyncGoTrueAdminAPI
7575from .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", {})
Original file line number Diff line number Diff 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+
351360class VerifyOtpParamsOptions(TypedDict):
352361 redirect_to: NotRequired[str]
353362 captcha_token: NotRequired[str]
You can’t perform that action at this time.
0 commit comments