简体   繁体   English

@react-native-firebase/auth:应用程序未授权 signInWithPhoneNumber 错误

[英]@react-native-firebase/auth: app not authorized Error in signInWithPhoneNumber

I am trying to set up a react-native project with firebase to signInWithPhoneNumber functionality.我正在尝试建立一个带有firebase的 react-native 项目来signInWithPhoneNumber功能。 I am receiving an error:我收到一个错误:

NativeFirebaseError: [auth/app-not-authorized] This app is not authorized to use Firebase Authentication. NativeFirebaseError: [auth/app-not-authorized] 此应用无权使用 Firebase 身份验证。 Please verify that the correct package name and SHA-1 are configured in the Firebase Console.请确认在 Firebase 控制台中配置了正确的包名称和 SHA-1。 [ App validation failed. [ 应用验证失败。 Is app running on a physical device?应用程序是否在物理设备上运行? ] ]

My Function call is as follows:我的函数调用如下:

import auth from '@react-native-firebase/auth';

Screen Class
....
getOtp = async () => {

....
auth()
      .signInWithPhoneNumber(`+91${phonenumber}`)
      .then(confirmResult =>
      ....
}

I have tried all the setup instructions for the Firebase connection.我已经尝试了 Firebase 连接的所有设置说明。

The Steps I have tried are:我尝试过的步骤是:

  • I have the same package name in the react-native android project and firebase console.我在 react-native android 项目和 firebase 控制台中有相同的包名。
  • Added the SHA1 from signingReport to Firebase Console.将签名报告中的 SHA1 添加到 Firebase 控制台。
  • Copied the google-services.json to android/app Folder.将 google-services.json 复制到 android/app 文件夹。
  • Linked the Firebase to Android Studio via Google Analytics.通过 Google Analytics 将 Firebase 链接到 Android Studio。

Giving Dummy Mobile Number for Testing works and has no issue but not with actual mobile number.提供虚拟手机号码进行测试有效并且没有问题,但与实际手机号码无关。 In android studio debugger, I am getting error issue displaying:在 android studio 调试器中,我收到错误问题显示:

I/BiChannelGoogleApi: [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzaq@8b3312c

D/Auth: signInWithPhoneNumber:verification:failed

package details in package.json: package.json 中的包详细信息:

    "@react-native-firebase/app": "^6.3.3",
    "@react-native-firebase/auth": "^6.3.3",
    "@react-native-firebase/firestore": "^6.3.3",
    "@react-native-firebase/functions": "^6.3.3",
    "@react-native-firebase/messaging": "^6.3.3",
    "@react-native-firebase/storage": "^6.3.3",
    "react": "^16.12.0",
    "react-native": "^0.61.5",

config in build.gradle(app): build.gradle(app) 中的配置:

...
dependencies {
    implementation "com.google.firebase:firebase-auth:19.2.0"
    //implementation "com.google.firebase:firebase-messaging"
    implementation "com.google.firebase:firebase-storage:17.0.0"
    implementation "com.google.firebase:firebase-firestore:17.1.5"
    implementation 'com.google.firebase:firebase-analytics:17.2.2'
    implementation 'com.android.support:multidex:1.0.3'

    implementation 'org.webkit:android-jsc:+'
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.0'
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:0.61.5"  // From node_modules
    implementation "com.google.android.gms:play-services-base:17.1.0"
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation "com.google.firebase:firebase-core:17.2.2"

}
...

config in build.gradle(projectname): build.gradle(项目名称)中的配置:

...
buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        // googlePlayServicesVersion = "16.1.0"
        androidMapsUtilsVersion = "0.5+"
    }
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven { url "https://jitpack.io" }
        maven { url "https://maven.google.com" }
    }
    dependencies {
        classpath('com.android.tools.build:gradle:3.5.3')
        classpath 'com.google.gms:google-services:4.3.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
...

I think in order to prevent abuse the firebase phone authentication wont work in emulator.我认为为了防止滥用 firebase 电话身份验证在模拟器中不起作用。 It only works with real device.它仅适用于真实设备。

But if you want it for testing purpose then you should add use some testing phone number in firebase console that will work in emulator.但是,如果您希望将其用于测试目的,那么您应该在 firebase 控制台中添加一些可在模拟器中使用的测试电话号码。

Go to your firebase console -> Authentication -> SIGN-IN Method -> Phone and check the "Phone numbers for testing (optional)" field.转到您的 Firebase 控制台 -> 身份验证 -> 登录方法 -> 电话并检查“测试电话号码(可选)”字段。

在此处输入图片说明

  1. In your root app folder, run keytool -list -v -keystore ./android/app/debug.keystore -alias androiddebugkey -storepass android -keypass android在您的根应用文件夹中,运行keytool -list -v -keystore ./android/app/debug.keystore -alias androiddebugkey -storepass android -keypass android
  2. Copy the returned SHA-1 and SHA-256 keys to the firebase console将返回的 SHA-1 和 SHA-256 密钥复制到 firebase 控制台
  3. Download the new google-services.json file in ./android/app./android/app下载新的google-services.json文件

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

相关问题 React Native Firebase auth().signInWithPhoneNumber() 在发布 APK 中返回意外错误 - React Native Firebase auth().signInWithPhoneNumber() return unexpected error in Release APK React Native仅Play Store应用显示错误应用未获得使用Firebase Auth的授权 - React native only play store app shows error app is not authorized to use firebase auth Firebase 和 react-native 中的“auth/app-not-authorized” - “auth/app-not-authorized” in Firebase with react-native auth().signInWithPhoneNumber() 不适用于 react-native - auth().signInWithPhoneNumber() not working for react-native firebase.notifications() 在 react-native-firebase 中抛出错误 - firebase.notifications() is throwing error in react-native-firebase 当应用程序运行时,react-native-firebase收到通知 - react-native-firebase receiving notification when app in running @react-native-firebase/messaging 错误:找不到符号 FirebaseInstanceId - @react-native-firebase/messaging error: cannot find symbol FirebaseInstanceId react-native-firebase 通知崩溃 - react-native-firebase notification crash 使用 react-native-firebase 启用 Proguard - Enable Proguard with react-native-firebase 安装react-native-firebase后,React Native Android应用程序崩溃 - React Native Android app crashes after installing react-native-firebase
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM