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

Commit 130bdb1

Browse files
authored
fix: add AuthOtpResponse (#419)
2 parents f03e518 + 97c4713 commit 130bdb1

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

gotrue/_async/gotrue_client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
model_dump,
3131
model_dump_json,
3232
model_validate,
33+
parse_auth_otp_response,
3334
parse_auth_response,
3435
parse_sso_response,
3536
parse_user_response,
@@ -46,6 +47,7 @@
4647
AuthMFAListFactorsResponse,
4748
AuthMFAUnenrollResponse,
4849
AuthMFAVerifyResponse,
50+
AuthOtpResponse,
4951
AuthResponse,
5052
CodeExchangeParams,
5153
DecodedJWTDict,
@@ -365,7 +367,7 @@ async def unlink_identity(self, identity):
365367
async def sign_in_with_otp(
366368
self,
367369
credentials: SignInWithPasswordlessCredentials,
368-
) -> AuthResponse:
370+
) -> AuthOtpResponse:
369371
"""
370372
Log in a user using magiclink or a one-time password (OTP).
371373
@@ -399,7 +401,7 @@ async def sign_in_with_otp(
399401
},
400402
},
401403
redirect_to=email_redirect_to,
402-
xform=parse_auth_response,
404+
xform=parse_auth_otp_response,
403405
)
404406
if phone:
405407
return await self._request(
@@ -413,7 +415,7 @@ async def sign_in_with_otp(
413415
"captcha_token": captcha_token,
414416
},
415417
},
416-
xform=parse_auth_response,
418+
xform=parse_auth_otp_response,
417419
)
418420
raise AuthInvalidCredentialsError(
419421
"You must provide either an email or phone number"

gotrue/_sync/gotrue_client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
model_dump,
3131
model_dump_json,
3232
model_validate,
33+
parse_auth_otp_response,
3334
parse_auth_response,
3435
parse_sso_response,
3536
parse_user_response,
@@ -46,6 +47,7 @@
4647
AuthMFAListFactorsResponse,
4748
AuthMFAUnenrollResponse,
4849
AuthMFAVerifyResponse,
50+
AuthOtpResponse,
4951
AuthResponse,
5052
CodeExchangeParams,
5153
DecodedJWTDict,
@@ -365,7 +367,7 @@ def unlink_identity(self, identity):
365367
def sign_in_with_otp(
366368
self,
367369
credentials: SignInWithPasswordlessCredentials,
368-
) -> AuthResponse:
370+
) -> AuthOtpResponse:
369371
"""
370372
Log in a user using magiclink or a one-time password (OTP).
371373
@@ -399,7 +401,7 @@ def sign_in_with_otp(
399401
},
400402
},
401403
redirect_to=email_redirect_to,
402-
xform=parse_auth_response,
404+
xform=parse_auth_otp_response,
403405
)
404406
if phone:
405407
return self._request(
@@ -413,7 +415,7 @@ def sign_in_with_otp(
413415
"captcha_token": captcha_token,
414416
},
415417
},
416-
xform=parse_auth_response,
418+
xform=parse_auth_otp_response,
417419
)
418420
raise AuthInvalidCredentialsError(
419421
"You must provide either an email or phone number"

gotrue/helpers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from .errors import AuthApiError, AuthError, AuthRetryableError, AuthUnknownError
1515
from .types import (
16+
AuthOtpResponse,
1617
AuthResponse,
1718
GenerateLinkProperties,
1819
GenerateLinkResponse,
@@ -72,6 +73,10 @@ def parse_auth_response(data: Any) -> AuthResponse:
7273
return AuthResponse(session=session, user=user)
7374

7475

76+
def parse_auth_otp_response(data: Any) -> AuthOtpResponse:
77+
return model_validate(AuthOtpResponse, data)
78+
79+
7580
def parse_link_response(data: Any) -> GenerateLinkResponse:
7681
properties = GenerateLinkProperties(
7782
action_link=data.get("action_link"),

gotrue/types.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ class AuthResponse(BaseModel):
8989
session: Union[Session, None] = None
9090

9191

92+
class AuthOtpResponse(BaseModel):
93+
user: None = None
94+
session: None = None
95+
message_id: Union[str, None] = None
96+
97+
9298
class OAuthResponse(BaseModel):
9399
provider: Provider
94100
url: str

0 commit comments

Comments
 (0)