supabase / supabase-flutter

Flutter integration for Supabase. This package makes it simple for developers to build secure and scalable products.
https://supabase.com/
MIT License
709 stars 167 forks source link

Phone Auth (SignupwithPhone) #132

Closed muhammed-amein closed 2 years ago

muhammed-amein commented 2 years ago
  Future<void> login(
    String name,
    String phone,
    String pass,
  ) async {
    print("Header");
    print("Header");
    print("Header");
    print("Header");
    print("Header");

    try {
      var response =
          await Supabase.instance.client.auth.signUpWithPhone(phone, pass);
      if (response.error != null) {
        print(response.error);
      }
    } catch (e) {
      print(e);
    }
  }
}

Now for three days, I been changing from and between Supabase and Supabase_flutter but it didn't work out for me both of them are giving me errors

GotrueError(message: type 'Null' is not a subtype of type 'Map<String, dynamic>' in type cast, statusCode: null)

Googled around but is not something relevant, Guys need help here?

dshukertjr commented 2 years ago

Hi @muhammed-amein,

Thank you for opening this issue. I did find the cause of this issue, but it was a bug that will prevent from proper error message from being displayed when using phone auth. If the authentication is successful, you should not be running into this error.

Have you enabled phone auth on your Supabase dashboard like this and connected your Twillio account?

Screen Shot 2022-06-22 at 13 31 43
muhammed-amein commented 2 years ago

Hello @dshukertjr

So basically I enabled phone Auth but I also disabled confirmation intentionally. Can I still achieve it this way without enabling confirmation or it is mandatory to have confirmation through Twilio or so on?

muhammed-amein commented 2 years ago

BTW I should add also that I tried email auth both gave me the same non responsive error. GotrueError(message: type 'Null' is not a subtype of type 'Map<String, dynamic>' in type cast, statusCode: null)

dshukertjr commented 2 years ago

@muhammed-amein You should be able to sign people up without connecting Twilio if you have phone confirmation turned off. I tried it earlier, and it worked for me without any error. Perhaps it's because you are not providing the country code with it? The following worked for me.

Supabase.instance.client.auth.signUpWithPhone('+81 70 0000 0000', 'password');

BTW I should add also that I tried email auth both gave me the same non responsive error. GotrueError(message: type 'Null' is not a subtype of type 'Map<String, dynamic>' in type cast, statusCode: null)

I am not able to reproduce this. Could you provide a code that you are using to make this happen?

muhammed-amein commented 2 years ago

@dshukertjr Does the phone number has to be formatted this way is it sensitive? Supabase.instance.client.auth.signUpWithPhone('+81 70 0000 0000', 'password'); In my use case I was passing the phone number this way, Supabase.instance.client.auth.signUpWithPhone('+251939290927', 'password');

dshukertjr commented 2 years ago

@muhammed-amein Hmm, that seems fine to me.

Would you be able to share a screenshot of your dashboard kind of like how I did earlier?

muhammed-amein commented 2 years ago
image

Here it is @dshukertjr