Search code examples
.nettwiliosmsauth0

Auth0 Passwordless Request - Error 21211 - Phone Number format


I am using the Auth0.AuthenticationApi for Passwordless. I have set up my client with Twilio Trial account and populated the Live Credentials of SID and AuthToken. When I make a call to StartPasswordlessSmsFlowAsync I get an error message about the format of the 'To' Phone Number. I have tried URL Encoding the Phone number as suggested in another post.

See code below.

    PasswordlessSmsRequest request = new PasswordlessSmsRequest();
    request.ClientId = "D2E7BMKdT6q6fBLi*****************";
    request.PhoneNumber = System.Net.WebUtility.UrlEncode(phoneNumber); // +353123456789
    var response = client.StartPasswordlessSmsFlowAsync(request);

This results in the error 21211:

    String does not match pattern: ^\+[0-9]{1,15}$

I have also tried to use the 'Try' feature under the Passwordless connections but that gives the same error.

Can someone please help out?


Solution

  • I ran into the same problem today. The error message is very confusing. The actual problem is that the sender phone number is not correct.

    With a Twilio trial account you need to request a trial number (there is a massive red button on the home page). This is the number you can use as sender for your messages from Auth0.