firebase - 凭据无效 - Unity Firebase
问题描述
过去两年我一直在使用 Unity 开发应用程序,直到现在才意识到我的手机身份验证无法正常工作。这是因为我在 Android 上进行开发,因此我一直只看到“verificationCompleted”的结果,而不是 codeSent。
换句话说,手动输入短信代码是行不通的。它说凭据无效。它不是!代码是对的。问题是,我将我的代码复制到另一个项目,然后它完美地工作。因此,我的代码可能没有问题。这里可能发生了什么?此外,一切正常,直到我应该验证代码本身。我收到了短信之类的。
当代码没有错误时,您何时会收到错误、无效的凭据?感觉什么都试过了!
提前感谢您的帮助!
这也是我的代码的一些图片。有些东西与身份验证无关,但是...
public void VerifyPhoneNumber(string _phoneNumber)
{
Debug.Log(String.Format("Auth is {0}, AuthenticationController is {1} and GameController is {2}.", auth, authenticationController, null));
var phoneAuthProvider = Firebase.Auth.PhoneAuthProvider.GetInstance(auth);
phoneAuthProvider.VerifyPhoneNumber(_phoneNumber, phoneAuthTimeoutMs, null,
verificationCompleted: (cred) =>
{
Debug.Log("Verification Completed");
MutualUiController.mutualUI.loadingPanel.gameObject.SetActive(false);
auth.SignInWithCredentialAsync(cred).ContinueWith(HandleSignInResult);
},
verificationFailed: (error) =>
{
Debug.Log("Verification Failed" + error);
},
codeSent: (id, token) =>
{
Debug.Log("Verification Code Sent");
phoneAuthVerificationId = id;
Debug.Log("ID: " + id + ", Token: " + token.ToString());
if (SceneController.currentScene == Scene.AuthenticationPage)
{
MutualUiController.mutualUI.loadingPanel.gameObject.SetActive(false);
Transform panel = GameObject.Find("AuthPageUI").GetComponent<AuthPageUI>().verificationPanel;
panel.gameObject.SetActive(true);
}
},
codeAutoRetrievalTimeOut: (id) =>
{
Debug.Log("Code Auto Timeout");
});
}
//verificationCompleted: (cred) =>
// {
// //Debug.Log("Verification Completed");
// //MutualUiController.mutualUI.loadingPanel.gameObject.SetActive(false);
// //auth.SignInWithCredentialAsync(cred).ContinueWith(HandleSignInResult);
// },
public void VerifyRecievedPhoneCode(string recievedCodeInput)
{
var phoneAuthProvider = Firebase.Auth.PhoneAuthProvider.GetInstance(auth);
var cred = phoneAuthProvider.GetCredential(phoneAuthVerificationId, recievedCodeInput);
auth.SignInWithCredentialAsync(cred).ContinueWith(HandleSignInResult);
}
解决方案
推荐阅读
- python - Django inlineformset_factory 添加行号
- google-cloud-platform - 在 GCE 上安装 Hashicorp 保险库
- nuget - 上传 NuGet 包,如何设置许可?
- java - Libgdx 桌面不运行 - 警告:发生了非法反射访问操作
- javascript - 隐藏的侧面板菜单的填充使其部分可见
- firebase - 在 Vuex 商店中找不到操作
- python - TypeError:不可散列的类型:sqlalchemy 插入查询的“列表”错误
- sql-server - SQL Server 文本导出保存在哪里?
- vba - 将 VBA 电子邮件程序转换为 HTML
- python - 如何在数据框中再添加一列