简体   繁体   English

具有真实电话号码的 Firebase PhoneAuth 无法使用,但白名单号码可以使用 - Android

[英]Firebase PhoneAuth with Real phone Number Is Not Working But Whitelisted Number is Working - Android

I am setting up Firebase Phone Auth in My App.我正在我的应用程序中设置 Firebase Phone Auth。 I set up a Test Phone Number and a verification code in firebase auth section Whitelist.我在 firebase auth 部分白名单中设置了一个测试电话号码和一个验证码。 When I test with this Number and code, it's working.当我用这个数字和代码进行测试时,它工作正常。 But When I Test With another number I got the Following error:但是当我用另一个号码测试时,出现以下错误:

onVerificationFailed    com.google.firebase.auth.FirebaseAuthInvalidCredentialsException:
    The request contains malformed or mismatching credentials [ App ID does not match the requested project.

side note: I also use facebook account kit in this android app, and It goes well.旁注:我也在这个安卓应用程序中使用了 facebook 帐户工具包,而且一切顺利。

Any Suggestions?有什么建议么?

Please put SHA certificate fingerprint in your firebase account.请将SHA 证书指纹放入您的firebase帐户中。

To get this follow these steps:为此, follow以下步骤:

1.Open your project in Android Studio 1.在Android Studio中打开你的项目
2.Click on Gradle Menu (From Right Side Panel ) 2.单击Gradle菜单(从右侧面板)
3.Expand Your Project -> Tasks -> 'Android' -> Double click on siginingReports 3.展开你的Project -> Tasks -> 'Android' -> 双击siginingReports
4.You will see SHA-1 and MD5 fingerprint in your run tab 4.您将在运行选项卡中看到SHA-1MD5指纹
5.Copy it and paste in your firebase console. 5.将其复制并粘贴到您的firebase控制台中。

Ah, (Alhamdulillah): At last I have solved the problem this way :啊,(Alhamdulillah):最后我用这种方式解决了这个问题:

What I have done wrong that, I have added the same android project and SHA key for Two Firebase Project.我做错了什么,我为两个 Firebase 项目添加了相同的 android 项目和 SHA 密钥。

The SHA key I have found for one app are Various according to build variant:我为一个应用程序找到的 SHA 密钥因构建变体而异:

I got one SHA key, When I debug my app.当我调试我的应用程序时,我得到了一个 SHA 密钥。 I got another SHA key, When I made release build for my app.当我为我的应用程序制作发布版本时,我得到了另一个 SHA 密钥。 I got third SHA key for the Same app When I submitted this app in Play Console.当我在 Play 控制台中提交此应用时,我获得了同一应用的第三个 SHA 密钥。 (From App signing Section) (来自应用程序签名部分)

So, I have Deleted My previous Firebase Project (because of no longer needed), And Create A new Firebase Project, Add this Android App and Add those All SHA key in Firebase: Project overview > settings > your apps > android apps > add SHA fingerprint section.所以,我删除了我以前的 Firebase 项目(因为不再需要),并创建一个新的 Firebase 项目,添加这个 Android 应用程序并在 Firebase 中添加所有 SHA 密钥:项目概述>设置>你的应用程序>安卓应用程序>添加 SHA指纹部分。

And, Then its Worked Well.而且,然后它运作良好。 Alhamdulillah. Alhamdulillah。

What worked for me:对我有用的是:

1) Updated SHA1 certificate fingerprint for all package names (prod, dev..) 1) 更新了所有包名称(prod、dev..)的 SHA1 证书指纹

2) Downloaded google-services.json and added to app/ 2) 下载google-services.json并添加到app/

3) Rebuild project 3)重建项目

It's the third step that I missed.这是我错过的第三步。 It wasn't suggested in any of these suggested answers, so I'm leaving the tip here.这些建议的答案中都没有建议,所以我把小费留在这里。 Hope that helps some of you.希望对你们中的一些人有所帮助。

  1. You should delete debug.keystore in ~./android/debug.keystore and in project android/app/debug.keystore您应该删除~./android/debug.keystore debug.keystore项目android/app/debug.keystore

  2. Create new keystore:创建新的密钥库:

$ keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000
  1. Copy ~./android/debug.keystore to project android/app/~./android/debug.keystore复制到项目android/app/
  2. Get SHA-1 and import firebase console like: https://stackoverflow.com/a/55774552获取 SHA-1 并导入 firebase 控制台,例如: https ://stackoverflow.com/a/55774552
  3. Download google-services.json and replace in android/app/google-services.json and rebuild the project.下载google-services.json并替换为android/app/google-services.json并重建项目。

Go to Google Play Console, click on your app after find Setup->App Signing .转到 Google Play 控制台,找到Setup->App Signing后单击您的应用。 In App signing key certificate copy key in SH-1 and upload to Project Setting Android in Firebase.SH-1中的App signing key certificate复制密钥并上传到 Firebase 中的 Project Setting Android。

delete your build folder and do invalidate/restart caches it will fix your issue 100%.删除您的构建文件夹并使缓存失效/重新启动,它将 100% 解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM