英文:
How do I implement phone auth using firebase in react native cli?
问题
最初,我使用Firebase实现了Google登录,现在我想在Firebase中实现电话验证。
以下是我遵循的步骤:
- 启用电话登录提供程序。
- 添加SHA证书指纹。
然后按照RN Firebase文档提供的代码进行操作。
但是我遇到了以下错误:
> 错误:[auth/app-not-authorized] 该应用程序未获授权使用Firebase身份验证。请验证Firebase控制台中是否配置了正确的包名称和SHA-1。[play_integrity_token中的请求字段无效]
>
> NativeFirebaseError:[auth/app-not-authorized] 该应用程序未获授权使用Firebase身份验证。请验证Firebase控制台中是否配置了正确的包名称和SHA-1。[play_integrity_token中的请求字段无效]
如何解决这个问题?
英文:
Initially, I implemented google sign in using Firebase and now I want to implement phone auth in firebase.
Here are the steps, I followed,
- Enabled the phone sign-in providers.
- Added SHA certificate fingerprints.
and Rest followed the code provided by RN Firebase docs
And I'm getting an error like
> Error: [auth/app-not-authorized] This app is not authorized to use Firebase Authentication. Please verify that the correct package name and SHA-1 are configured in the Firebase Console. [ Invalid request fields in play_integrity_token ]
>
> NativeFirebaseError: [auth/app-not-authorized] This app is not authorized to use Firebase Authentication. Please verify that the correct package name and SHA-1 are configured in the Firebase Console. [ Invalid request fields in play_integrity_token ]
How to solve this?
答案1
得分: 1
我遇到了相同的问题,我认为我已经找到了解决方法,截至2023年6月对我有效。以下是我所做的:
- 检查 SHA-1 和 SHA-256,分别来自本地生成和 Play 商店,在 "发布" > "设置" > "应用完整性" > "应用签名" 中,这是您在 Firebase 项目设置中设置的。
- 将
@react-native-firebase/auth
升级到 v17.x.x。从 v17.x.x 开始支持 Play 完整性。 - 在在线临时手机号码或真实设备上测试可用的移动号码,似乎 Play 完整性只适用于已签名的发布版。
- React Native Firebase 仅建议确保完成步骤 1 和 2,但没有提到 "开始之前的步骤"。明确地说,它应该在
/app/build.gradle
中,而不是在 Firebase 文档中定义的/build.gradle
。请参考截图:
最后,请确保在 Play 商店上传 .aab
时没有关于 safenet 废弃的警告。
希望能帮助您,否则,我将很乐意听取更新的解决方案。截止到我撰写这篇文章时,我无法在一个地方找到解决方案,不得不在不同的地方自己摸索。
英文:
I encounter the same issue and I think I figure it out, which works for me as of June 2023. Here's what i've done:
- Review SHA-1 and SHA-256 from both locally generated and playstore under Release > Setup > App Integrity > App Signing you set in firebase project settings.
- Upgrade
@react-native-firebase/auth
to v17.x.x. Play Integrity is supported starting v17.x.x - Test temporary mobile number available online or real mobile number in a real device (not simulator), it seems that Play Integrity only works with a signed release
- React Native Firebase only suggest to make sure you complete step 1 and 2 but not mentioned "before we begin steps". To be clear, it should be in
/app/build.gradle
and not/build.gradle
as define in firebase docs. See screenshot:
Lastly, make sure when upload .aab
in playstore you didn't get warning about safenet deprecation
Hope it helps, otherwise, I would be happy to hear what are updated solutions. As of this writing, I can't find a solution in one place. I had to figure out this myself in different places.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论