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

Commit 85f94f2

Browse files
committed
update async client and type naming
1 parent f3d35c7 commit 85f94f2

File tree

3 files changed

+63
-26
lines changed

3 files changed

+63
-26
lines changed

supabase_auth/_async/gotrue_client.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@
6161
Options,
6262
Provider,
6363
Session,
64+
SignInAnonymouslyCredentials,
6465
SignInWithOAuthCredentials,
6566
SignInWithPasswordCredentials,
6667
SignInWithPasswordlessCredentials,
68+
SignInWithSSOCredentials,
6769
SignOutOptions,
6870
SignUpWithPasswordCredentials,
6971
Subscription,
@@ -149,6 +151,34 @@ async def initialize_from_url(self, url: str) -> None:
149151

150152
# Public methods
151153

154+
async def sign_in_anonymously(
155+
self, credentials: Union[SignInAnonymouslyCredentials, None] = None
156+
) -> AuthResponse:
157+
"""
158+
Creates a new anonymous user.
159+
"""
160+
self._remove_session()
161+
if credentials is None:
162+
credentials = {"options": {}}
163+
options = credentials.get("options", {})
164+
data = options.get("data") or {}
165+
captcha_token = options.get("captcha_token")
166+
response = self._request(
167+
"POST",
168+
"signup",
169+
body={
170+
"data": data,
171+
"gotrue_meta_security": {
172+
"captcha_token": captcha_token,
173+
},
174+
},
175+
xform=parse_auth_response,
176+
)
177+
if response.session:
178+
self._save_session(response.session)
179+
self._notify_all_subscribers("SIGNED_IN", response.session)
180+
return response
181+
152182
async def sign_up(
153183
self,
154184
credentials: SignUpWithPasswordCredentials,

supabase_auth/_sync/gotrue_client.py

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,17 @@
6161
Options,
6262
Provider,
6363
Session,
64+
SignInAnonymouslyCredentials,
6465
SignInWithOAuthCredentials,
6566
SignInWithPasswordCredentials,
6667
SignInWithPasswordlessCredentials,
68+
SignInWithSSOCredentials,
6769
SignOutOptions,
6870
SignUpWithPasswordCredentials,
6971
Subscription,
7072
UserAttributes,
7173
UserResponse,
72-
VerifyOtpParams, SignInAnonymouslyCredentials,
74+
VerifyOtpParams,
7375
)
7476
from .gotrue_admin_api import SyncGoTrueAdminAPI
7577
from .gotrue_base_api import SyncGoTrueBaseAPI
@@ -149,6 +151,34 @@ def initialize_from_url(self, url: str) -> None:
149151

150152
# Public methods
151153

154+
def sign_in_anonymously(
155+
self, credentials: Union[SignInAnonymouslyCredentials, None] = None
156+
) -> AuthResponse:
157+
"""
158+
Creates a new anonymous user.
159+
"""
160+
self._remove_session()
161+
if credentials is None:
162+
credentials = {"options": {}}
163+
options = credentials.get("options", {})
164+
data = options.get("data") or {}
165+
captcha_token = options.get("captcha_token")
166+
response = self._request(
167+
"POST",
168+
"signup",
169+
body={
170+
"data": data,
171+
"gotrue_meta_security": {
172+
"captcha_token": captcha_token,
173+
},
174+
},
175+
xform=parse_auth_response,
176+
)
177+
if response.session:
178+
self._save_session(response.session)
179+
self._notify_all_subscribers("SIGNED_IN", response.session)
180+
return response
181+
152182
def sign_up(
153183
self,
154184
credentials: SignUpWithPasswordCredentials,
@@ -337,29 +367,6 @@ def sign_in_with_oauth(
337367
url = self._get_url_for_provider(provider, params)
338368
return OAuthResponse(provider=provider, url=url)
339369

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-
363370
def link_identity(self, credentials):
364371
provider = credentials.get("provider")
365372
options = credentials.get("options", {})

supabase_auth/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,10 @@ class SignInWithSSOOptions(TypedDict):
349349

350350

351351
class SignInAnonymouslyCredentials(TypedDict):
352-
options: NotRequired[SignInAnonymouslySSOOptions]
352+
options: NotRequired[SignInAnonymouslyCredentialsOptions]
353353

354354

355-
class SignInAnonymouslySSOOptions(TypedDict):
355+
class SignInAnonymouslyCredentialsOptions(TypedDict):
356356
data: NotRequired[Any]
357357
captcha_token: NotRequired[str]
358358

0 commit comments

Comments
 (0)