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

supabase.auth.sign_in_with_otp with phone login throws error  #321

@kevinseo16

Description

@kevinseo16

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

Screenshots
Screenshot 2023-04-07 at 5 47 33 PM

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions