“unknown status code: 17042 Invalid format” error when using verification code

Total
1
Shares

Problem: I am getting the following error when entering the phone number to receive a verification code: Error FirebaseAuth [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17042 Invalid format. I entered the number as so +1xxxxxxxxxx.

What I would like to be able to do ultimately is receive the verification code and verify to allow the user to get back in the game.

The code below is what I am using to send the sms verification code and to verify:

 void SMSVerification(string phone, bool consent_sent)
{
    if (consent_sent == true)
    {
        ///Application.OpenURL("sms:" + sms);

        var phoneAuthProvider = Firebase.Auth.PhoneAuthProvider.GetInstance(auth);
        phoneAuthProvider.VerifyPhoneNumber(phone, phoneAuthTimeoutMs, null,
        verificationCompleted: (cred) =>
        {
            if (signInAndFetchProfile)
            {
                auth.SignInAndRetrieveDataWithCredentialAsync(cred).ContinueWith(HandleSignInWithSignInResult);
                Debug.Log("SignInAndRetrieveDataWithCredentialAsync");
            }
            else
            {
                auth.SignInWithCredentialAsync(cred).ContinueWith(HandleSignInWithUser);
                Debug.Log("SignInWithCredentialAsync");
            }
        },
        verificationFailed: (error) =>
        {
            Debug.Log("Verification Failed");
        },
        codeSent: (id, token) =>
        {
            phoneAuthVerificationId = id;
            Debug.Log("Codesent successful");
        },
        codeAutoRetrievalTimeOut: (id) =>
        {
            Debug.Log("CodeTiemOut");
        });
    }
}

public void VerifyReceivedPhoneCode()
    {
        var phoneAuthProvider = Firebase.Auth.PhoneAuthProvider.GetInstance(auth);
        // receivedCode should have been input by the user.

        //string code = verificationcodeInputField.text.ToString();
        string code = "Place Holder";
        Debug.Log("The Code for verification is" + code);
        var cred = phoneAuthProvider.GetCredential(phoneAuthVerificationId, code);
        if (signInAndFetchProfile)
        {
            auth.SignInAndRetrieveDataWithCredentialAsync(cred).ContinueWith(
            HandleSignInWithSignInResult);
        }
        else
        {
            auth.SignInWithCredentialAsync(cred).ContinueWith(HandleSignInWithUser);
        }
    }

Any help would be appreciated.


Solution

According to the API, (not listed under unity for some reason) the number format seems to be very specific for the API.

The format seems to require

+1 650-555-3434 (not a real number)

But the format you provided, might not work.

+1xxxxxxxxxx
Leave a Reply

Your email address will not be published. Required fields are marked *