GVKun编程网logo

获取Firebase Phone Auth OTP时出错(获取用户openld失败是什么意思)

5

这篇文章主要围绕获取FirebasePhoneAuthOTP时出错和获取用户openld失败是什么意思展开,旨在为您提供一份详细的参考资料。我们将全面介绍获取FirebasePhoneAuthOTP时

这篇文章主要围绕获取Firebase Phone Auth OTP时出错获取用户openld失败是什么意思展开,旨在为您提供一份详细的参考资料。我们将全面介绍获取Firebase Phone Auth OTP时出错的优缺点,解答获取用户openld失败是什么意思的相关问题,同时也会为您带来React Native Firebase Phone Auth - auth/session-expired 错误、React Native Firebase Phone Auth - auth/session-expired 错误 安卓、react-native fb phone auth android signInWithPhoneNumber error [auth/app-not-authorized] ... [一个safety_net_token已通过、setter 'phone=' 被调用为 null I/flutter (32048): Receiver: null I/flutter (32048): 尝试调用: phone="48787487"的实用方法。

本文目录一览:

获取Firebase Phone Auth OTP时出错(获取用户openld失败是什么意思)

获取Firebase Phone Auth OTP时出错(获取用户openld失败是什么意思)

如何解决获取Firebase Phone Auth OTP时出错

我正在尝试实施Firebase电话验证。我已在Firebase控制台上启用电话验证。我已经生成了密钥库,并将SHA签名添加到了控制台。

依赖项:

dependencies {
    def multidex_version = "2.0.1"
    implementation platform(''com.google.firebase:firebase-bom:26.0.0'')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation ''com.google.firebase:firebase-analytics''
    implementation "androidx.multidex:multidex:$multidex_version"
    implementation ''com.google.firebase:firebase-auth''
    implementation ''com.google.firebase:firebase-core''
    implementation ''com.google.firebase:firebase-analytics''
    implementation ''com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava''

}

phone_verification.dart

                await FirebaseAuth.instance.verifyPhoneNumber(
                  phoneNumber: ''+1234567890'',verificationCompleted: (PhoneAuthCredential credential) {
                    print(''verificationCompleted'');
                    
                  },verificationFailed: (FirebaseAuthException e) {
                    print(''verificationFailed'');
                    if (e.code == ''invalid-phone-number'') {
                      print(''The provided phone number is not valid.'');
                    }
                    else {
                      print(''Some error occoured: $e'');
                    }
                  },codeSent: (String verificationId,int resendToken) async {
                    print(''codeSent'');

                    // Update the UI - wait for the user to enter the SMS code
                    String smsCode = ''123456'';

                    // Create a PhoneAuthCredential with the code
                    PhoneAuthCredential phoneAuthCredential = PhoneAuthProvider.credential(verificationId: verificationId,smsCode: smsCode);
                  
                  },timeout: const Duration(seconds: 60),codeAutoRetrievalTimeout: (String verificationId) {
                    print("Timeout: $verificationId");
                  },);

执行以上程序段时,收到以下错误。 控制台输出:

E/FirebaseAuth: [GetAuthDomainTask] Error getting project config. Failed with {
      "error": {
        "code": 400,"message": "INVALID_CERT_HASH","errors": [
          {
            "message": "INVALID_CERT_HASH","domain": "global","reason": "invalid"
          }
        ]
      }
    }
     400
V/FA: Recording user engagement,ms: 1165
E/zza: Failed to get reCAPTCHA token - calling backend without app verification

解决方法

在Firebase控制台的身份验证 下,

启用电话选项

,

@CubeRootX和@ user13864571

您的与SHA1和SHA256密钥有关的问题。您必须添加它们以对您的证书进行身份验证。

转到

  • 项目的Firebase控制台
  • 身份验证
  • 项目设置(通过“项目概述”附近的“设置”按钮)
  • 添加指纹
  • 添加密钥库的SHA-1和SHA-256值。

您可以像这样从gradle获取密钥库。

./ gradlew signingReport

请阅读以获取更多信息:https://firebase.google.com/docs/auth/android/phone-auth#enable-app-verification

,

错误 400 表示请求错误,可能是以下三个原因中的任何一个:-

  1. 检查是否在 Firebase 控制台中启用了电话身份验证选项。启用它。
  2. 检查 Google cloud console 中是否启用了 Android Device Check API。启用它。
  3. 检查 SHA-1 和 SHA-256 是否已添加到您的 Firebase 项目中。添加如下:

在 firebase 控制台中打开您的项目 -> 转到项目设置 -> 点击添加指纹(在页面底部)-> 在那里添加 SHA-1 和 SHA-256 值。 Image for reference

您可以按如下方式获取您的 android studio 项目的 SHA 值:-

点击右上角的gradle->task->android->signingReport->运行signatureReort后获取底部的SHA值Image for reference

如果问题未解决,请关注 documentation。

React Native Firebase Phone Auth - auth/session-expired 错误

React Native Firebase Phone Auth - auth/session-expired 错误

如何解决React Native Firebase Phone Auth - auth/session-expired 错误

React Native Firebase Phone Auth - 当我要验证 OTP 时显示 auth/session-expired 错误。

build.gradle/app

    apply plugin: ''com.android.application''
    apply plugin: ''com.google.gms.google-services''
    

      implementation platform(''com.google.firebase:firebase-bom:27.0.0'')
        implementation ''com.google.firebase:firebase-analytics''
        implementation ''com.google.firebase:firebase-auth''
    implementation "androidx.browser:browser:1.2.0"
    
   

build.gradle/android

    buildscript {
        ext {
            buildToolsversion = "28.0.3"
            minSdkVersion = 21
            compileSdkVersion = 28
            targetSdkVersion = 28
             ndkVersion = "20.1.5948944"
         }
    
  

classpath("com.android.tools.build:gradle:3.5.2")
  classpath (''com.google.gms:google-services:4.3.5'')
    PLEASE HELP ME

React Native Firebase Phone Auth - auth/session-expired 错误 安卓

React Native Firebase Phone Auth - auth/session-expired 错误 安卓

如何解决React Native Firebase Phone Auth - auth/session-expired 错误 安卓

这是我来自 rnfirebase.io 的代码。

我在按下登录按钮后收到短信验证码。但是在输入验证码后,firebase 会返回这个 [auth/session-expired] 错误。

[错误:[auth/session-expired] 短信代码已过期。请重新发送验证码以重试。]

同样 setConfirm(confirmation) 也不起作用。它再次返回一个空值。

我该如何解决这个问题?谢谢!

  1. import React,{ useState } from "react";
  2. import { View,Text,StyleSheet,Button,TextInput } from "react-native";
  3. import auth from "@react-native-firebase/auth";
  4. import colors from "../../config/colors";
  5. // create a component
  6. const UyeOlScreen = () => {
  7. // If null,no SMS has been sent
  8. const [confirm,setConfirm] = useState(null);
  9. const [code,setCode] = useState("");
  10. // Handle the button press
  11. async function signInWithPhoneNumber(phoneNumber) {
  12. const confirmation = await auth().signInWithPhoneNumber(phoneNumber);
  13. setConfirm(confirmation);
  14. }
  15. async function confirmCode() {
  16. try {
  17. await confirm.confirm(code);
  18. } catch (error) {
  19. console.log(error);
  20. }
  21. }
  22. if (!confirm) {
  23. return (
  24. <Button
  25. title="Phone Number Sign In"
  26. onPress={() => signInWithPhoneNumber(`+123456789`)}
  27. />
  28. );
  29. }
  30. return (
  31. <>
  32. <TextInput value={code} onChangeText={(text) => setCode(text)} />
  33. <Button title="Confirm Code" onPress={() => confirmCode()} />
  34. </>
  35. );
  36. };
  37. //make this component available to the app
  38. export default UyeOlScreen; ```

解决方法

这帮助我解决了这个问题:How to use Firebase''s ''verifyPhoneNumber()'' to confirm phone # ownership without using # to sign-in?

当然,我必须进行一些调整才能使其适合我。具体我把代码拿出来:

  1. firebase
  2. .firestore()
  3. .collection(''users'')
  4. .where(''phoneNumber'',''=='',this.state.phoneNumber)
  5. .get()
  6. .then((querySnapshot) => {
  7. if (!querySnapshot.empty) {
  8. // User found with this phone number.
  9. throw new Error(''already-exists'');
  10. }

我认为这是处理可以与我不使用的 firebase 一起使用的存储。

我也拿出来了:

  1. let fbWorkerApp = firebase.apps.find(app => app.name === ''auth-worker'')
  2. || firebase.initializeApp(firebase.app().options,''auth-worker'');
  3. fbWorkerAuth = fbWorkerApp.auth();
  4. fbWorkerAuth.setPersistence(firebase.auth.Auth.Persistence.NONE); // disables caching of account credentials

并且只是使用“auth()”代替 fbWorkerAuth 因为我已经在这样做了:

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

还有一个 catch 块中有一个小错误,它有“err”,应该是“error”。

否则它为我解决了这个问题。太糟糕了,所有与此相关的文档都向我们指出了一个不起作用的示例!

react-native fb phone auth android signInWithPhoneNumber error [auth/app-not-authorized] ... [一个safety_net_token已通过

react-native fb phone auth android signInWithPhoneNumber error [auth/app-not-authorized] ... [一个safety_net_token已通过

如何解决react-native fb phone auth android signInWithPhoneNumber error [auth/app-not-authorized] ... [一个safety_net_token已通过

我已经使用了 firebase phone auth 的 signInWithPhoneNumber 功能,并按照手册中的每一步进行操作,直到该功能可以用于 ios 真实设备的真实电话号码(不是测试电话号码),但仍然停留在 android 真实设备上。

>

使用该功能时收到此消息

" [错误:[auth/app-not-authorized] 此应用未获授权使用 Firebase 身份验证。请验证 Firebase 控制台中是否配置了正确的包名称和 SHA-1。[ 已传递安全网络令牌,但在 Firebase 控制台中未注册匹配的 SHA-256。请确保此应用的 packageName/SHA256 对已在 Firebase 控制台中注册。]] "

我使用了各种手动方法来获取 SHA-1 和 SHA-256 密钥

keytool -list -v
-别名 androiddebugkey -keystore ~/.android/debug.keystore

./gradlew 签名报告

android studio gradle 中的signingReport

两种方法具有相同的键值。

我在 firebase 控制台中输入了 SHA-1 和 SHA-256 密钥 并转到“App Check”注册“SafetyNet”直到状态“Registered”

我已将“google-services.json”文件再次下载到 react-native 项目文件夹 android/app 并使用

"cd android && ./gradlew clean && cd - && npx react-native run-android"

我仍然收到相同的错误消息。

我被这个问题困了整整 2 天,请帮帮我。

setter 'phone=' 被调用为 null I/flutter (32048): Receiver: null I/flutter (32048): 尝试调用: phone=

setter 'phone=' 被调用为 null I/flutter (32048): Receiver: null I/flutter (32048): 尝试调用: phone="48787487"

如何解决setter ''phone='' 被调用为 null I/flutter (32048): Receiver: null I/flutter (32048): 尝试调用: phone="48787487"

处理手势时抛出以下 NoSuchMethodError: 方法 ''phone'' 被调用为 null。 接收器:空 试过打电话:phone="1235451"

我正在创建一个页面来更新用户注册数据,当我点击更新时出现此错误,但没有任何反应。我现在正在学习颤振,还有很多我不知道的,有人可以帮助我吗? [用户飞镖文件]:https://i.stack.imgur.com/RLimv.png

  1. import ''package:Flutter/material.dart'';
  2. import ''../../generated/l10n.dart'';
  3. import ''../models/user.dart'';
  4. import ''../helpers/helper.dart'';
  5. import ''../elements/BlockButtonWidget.dart'';
  6. import ''../helpers/app_config.dart'' as config;
  7. import ''package:mvc_pattern/mvc_pattern.dart'';
  8. import ''../repository/user_repository.dart'' as repository;
  9. import ''../repository/user_repository.dart'';
  10. class SettingsController extends ControllerMVC {
  11. GlobalKey<FormState> loginFormKey;
  12. GlobalKey<ScaffoldState> scaffoldKey;
  13. SettingsController() {
  14. loginFormKey = new GlobalKey<FormState>();
  15. this.scaffoldKey = new GlobalKey<ScaffoldState>();
  16. }
  17. void update(User user) async {
  18. user.devicetoken = null;
  19. repository.update(user).then((value) {
  20. scaffoldKey?.currentState?.showSnackBar(SnackBar(
  21. content: Text("Atualizado com Sucesso"),));
  22. });
  23. }
  24. }
  25. class ProfileSettingsDialog extends StatefulWidget {
  26. final User user;
  27. final VoidCallback onChanged;
  28. ProfileSettingsDialog({Key key,@required this.user,this.onChanged}) : super(key: key);
  29. @override
  30. _ProfileSettingsDialogState createState() => _ProfileSettingsDialogState();
  31. }
  32. class _ProfileSettingsDialogState extends State<ProfileSettingsDialog> {
  33. GlobalKey<FormState> _profileSettingsFormKey = new GlobalKey<FormState>();
  34. @override
  35. Widget build(BuildContext context) {
  36. return WillPopScope(
  37. onWillPop: Helper.of(context).onWillPop,child: Scaffold(
  38. resizetoAvoidBottomPadding: false,body: Stack(
  39. alignment: AlignmentDirectional.topCenter,children: <Widget>[
  40. Positioned(
  41. top: 0,child: Container(
  42. width: config.App(context).appWidth(100),height: config.App(context).appHeight(29.5),decoration: Boxdecoration(color: Theme.of(context).accentColor),),Positioned(
  43. top: config.App(context).appHeight(29.5) - 120,child: Container(
  44. width: config.App(context).appWidth(84),child: Text(
  45. S.of(context).lets_start_with_register,style: Theme.of(context).textTheme.headline2.merge(TextStyle(color: Theme.of(context).primaryColor)),Positioned(
  46. top: config.App(context).appHeight(29.5) - 50,child: Container(
  47. decoration: Boxdecoration(color: Theme.of(context).primaryColor,borderRadius: BorderRadius.all(Radius.circular(10)),BoxShadow: [
  48. BoxShadow(
  49. blurRadius: 50,color: Theme.of(context).hintColor.withOpacity(0.2),)
  50. ]),margin: EdgeInsets.symmetric(
  51. horizontal: 20,padding: EdgeInsets.symmetric(vertical: 50,horizontal: 27),width: config.App(context).appWidth(88),// height: config.App(context).appHeight(55),child: Form(key: _ProfileSettingsFormKey,child: Column(
  52. crossAxisAlignment: CrossAxisAlignment.stretch,mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[
  53. TextFormField(
  54. keyboardType: TextInputType.text,onSaved: (input) => widget.user.phone = input,validator: (input) => input.trim().length < 3 ? S.of(context).not_a_valid_phone : null,decoration: Inputdecoration(
  55. labelText: "Celular",labelStyle: TextStyle(color: Theme.of(context).accentColor),contentPadding: EdgeInsets.all(12),hintText: S.of(context).john_doe,hintStyle: TextStyle(color: Theme.of(context).focusColor.withOpacity(0.7)),prefixIcon: Icon(Icons.person_outline,color: Theme.of(context).accentColor),border: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).focusColor.withOpacity(0.2))),focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).focusColor.withOpacity(0.5))),enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).focusColor.withOpacity(0.2))),SizedBox(height: 30),TextFormField(
  56. keyboardType: TextInputType.text,onSaved: (input) => widget.user.address = input,validator: (input) => input.trim().length < 3 ? S.of(context).not_a_valid_address : null,decoration: Inputdecoration(
  57. labelText: "Endereço",hintText: ''johndoe@gmail.com'',prefixIcon: Icon(Icons.alternate_email,TextFormField(
  58. keyboardType: TextInputType.text,onSaved: (input) => widget.user.bio = input,validator: (input) => input.trim().length < 3 ? S.of(context).not_a_valid_biography : null,decoration: Inputdecoration(
  59. labelText: "Biografia",BlockButtonWidget(
  60. text: Text(
  61. S.of(context).register,style: TextStyle(color: Theme.of(context).primaryColor),color: Theme.of(context).accentColor,onpressed: () {
  62. _profileSettingsFormKey.currentState.save();
  63. widget.onChanged();
  64. Navigator.pop(context);
  65. update(currentUser.value);
  66. //setState(() {});
  67. },// widget.update(currentUser.value);
  68. ),SizedBox(height: 25),// FlatButton(
  69. // onpressed: () {
  70. // Navigator.of(context).pushNamed(''/MobiLeverification'');
  71. // },// padding: EdgeInsets.symmetric(vertical: 14),// color: Theme.of(context).accentColor.withOpacity(0.1),// shape: StadiumBorder(),// child: Text(
  72. // ''Register with Google'',// textAlign: TextAlign.start,// style: TextStyle(
  73. // color: Theme.of(context).accentColor,// ),// ),// ),],);
  74. }
  75. Inputdecoration getInputdecoration({String hintText,String labelText}) {
  76. return new Inputdecoration(
  77. hintText: hintText,labelText: labelText,hintStyle: Theme.of(context).textTheme.bodyText2.merge(
  78. TextStyle(color: Theme.of(context).focusColor),enabledBorder: UnderlineInputBorder(borderSide: BorderSide(color: Theme.of(context).hintColor.withOpacity(0.2))),focusedBorder: UnderlineInputBorder(borderSide: BorderSide(color: Theme.of(context).hintColor)),floatingLabelBehavior: FloatingLabelBehavior.auto,labelStyle: Theme.of(context).textTheme.bodyText2.merge(
  79. TextStyle(color: Theme.of(context).hintColor),);
  80. }
  81. }

解决方法

我看不到您的 User 类的定义,但似乎属性 phone 被定义为 final(因此,您会收到 setter 方法在 null 上调用的错误)。

您需要使属性可变(非最终的,例如 String phone),以便能够以与您的代码相同的方式更改其值。

关于获取Firebase Phone Auth OTP时出错获取用户openld失败是什么意思的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于React Native Firebase Phone Auth - auth/session-expired 错误、React Native Firebase Phone Auth - auth/session-expired 错误 安卓、react-native fb phone auth android signInWithPhoneNumber error [auth/app-not-authorized] ... [一个safety_net_token已通过、setter 'phone=' 被调用为 null I/flutter (32048): Receiver: null I/flutter (32048): 尝试调用: phone="48787487"的相关信息,请在本站寻找。

本文标签: