【问题标题】:"unknown status code: 17042 Invalid format" error when using verification code使用验证码时出现“未知状态码:17042 Invalid format”错误
【发布时间】:2021-05-21 12:22:00
【问题描述】:

问题:输入电话号码以接收验证码时出现以下错误:Error FirebaseAuth [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17042 Invalid format。我输入的号码是+1xxxxxxxxxx

我最终希望能够做的是接收验证码并验证以允许用户重新进入游戏。

下面的代码是我用来发送短信验证码和验证的:

 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);
        }
    }

任何帮助将不胜感激。

【问题讨论】:

  • 请记住让您的问题标题成为您问题的摘要,而不是一系列标签。我已经为你编辑了。
  • 我查看了文档,您使用的是+1 650-555-3434 格式还是使用+1650-555-3434 格式,这似乎相当具体。 (注意:这些不是真实的电话号码,来自谷歌的例子。
  • @DekuDesu:你能把它发给我的文档中的什么地方吗?
  • 这适用于 Android,但我认为 API 非常相似,它是 here under Test With Fictional Phone Numbers 它提到了长度和格式要求,它们提供了一个与您所说的不同的示例。
  • @DekuDesu:谢谢。我会尝试格式化数字

标签: c# unity3d firebase-realtime-database


【解决方案1】:

According to the API,(由于某种原因未在统一列表中列出)数字格式似乎非常特定于 API。

格式好像需要

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

但是您提供的格式可能不起作用。

+1xxxxxxxxxx

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-23
    • 2017-10-28
    • 2022-10-10
    相关资源
    最近更新 更多