-
-
Notifications
You must be signed in to change notification settings - Fork 53
supabase.auth.sign_in_with_otp with phone login throws error #321
Description
Describe the bug
While the following function supabase.auth.sign_in_with_otp(params={"phone": phone, "token": verification_code, "type": "sms"}) successfully sends an OTP to the phone number described, the request returns the following error.
.
.
.
File "/Users/zzan/Desktop/repositories/zzan-backend-fastapi/./app/routers/users.py", line 23, in post_signin_phone
data = supabase.auth.sign_in_with_otp(credentials={"phone": phone})
File "/Users/zzan/Desktop/repositories/zzan-backend-fastapi/venv/lib/python3.9/site-packages/gotrue/_sync/gotrue_client.py", line 299, in sign_in_with_otp
return self._request(
File "/Users/zzan/Desktop/repositories/zzan-backend-fastapi/venv/lib/python3.9/site-packages/gotrue/_sync/gotrue_base_api.py", line 119, in _request
raise handle_exception(e)
gotrue.errors.AuthRetryableError: 5 validation errors for User
id
field required (type=value_error.missing)
app_metadata
field required (type=value_error.missing)
user_metadata
field required (type=value_error.missing)
aud
field required (type=value_error.missing)
created_at
field required (type=value_error.missing)
To Reproduce
from supabase import create_client, Client
url: str = "SUPABASE_API_URL"
key: str = "SUPABASE_API_KEY"
supabase: Client = create_client(url, key)
phone: str = "PHONE_NUMBER_WITH_COUNTRY_CODE"
data = supabase.auth.sign_in_with_otp(credentials={"phone": phone})
print(data)
Expected behavior
Should return an AuthResponse class.
class AuthResponse(BaseModel):
user: Union[User, None] = None
session: Union[Session, None] = None
Environment (please complete the following information):
- Python: 3.9.6
- OS: macOS Ventura (v. 13.2.1)
Additional context
It seems that there is an issue occurring when the sign_in_with_otp function is called. The problem seems to be happening when the function tries to return the result of self._request(...), which is a function call in the gotrue_base_api.py module. When the _request function is called, the result variable is an empty dictionary {} which may be causing an issue during the parse_auth_response function invocation in the gotrue package.
Let me know what you guys think! I would love to try to help debug this issue as well.
