这篇文章主要围绕获取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失败是什么意思)
- 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时出错
我正在尝试实施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
解决方法
启用电话选项
,@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 表示请求错误,可能是以下三个原因中的任何一个:-
- 检查是否在 Firebase 控制台中启用了电话身份验证选项。启用它。
- 检查 Google cloud console 中是否启用了 Android Device Check API。启用它。
- 检查 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 - 当我要验证 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 错误 安卓
这是我来自 rnfirebase.io 的代码。
我在按下登录按钮后收到短信验证码。但是在输入验证码后,firebase 会返回这个 [auth/session-expired] 错误。
[错误:[auth/session-expired] 短信代码已过期。请重新发送验证码以重试。]
同样 setConfirm(confirmation) 也不起作用。它再次返回一个空值。
我该如何解决这个问题?谢谢!
import React,{ useState } from "react";
import { View,Text,StyleSheet,Button,TextInput } from "react-native";
import auth from "@react-native-firebase/auth";
import colors from "../../config/colors";
// create a component
const UyeOlScreen = () => {
// If null,no SMS has been sent
const [confirm,setConfirm] = useState(null);
const [code,setCode] = useState("");
// Handle the button press
async function signInWithPhoneNumber(phoneNumber) {
const confirmation = await auth().signInWithPhoneNumber(phoneNumber);
setConfirm(confirmation);
}
async function confirmCode() {
try {
await confirm.confirm(code);
} catch (error) {
console.log(error);
}
}
if (!confirm) {
return (
<Button
title="Phone Number Sign In"
onPress={() => signInWithPhoneNumber(`+123456789`)}
/>
);
}
return (
<>
<TextInput value={code} onChangeText={(text) => setCode(text)} />
<Button title="Confirm Code" onPress={() => confirmCode()} />
</>
);
};
//make this component available to the app
export default UyeOlScreen; ```
解决方法
这帮助我解决了这个问题:How to use Firebase''s ''verifyPhoneNumber()'' to confirm phone # ownership without using # to sign-in?
当然,我必须进行一些调整才能使其适合我。具体我把代码拿出来:
firebase
.firestore()
.collection(''users'')
.where(''phoneNumber'',''=='',this.state.phoneNumber)
.get()
.then((querySnapshot) => {
if (!querySnapshot.empty) {
// User found with this phone number.
throw new Error(''already-exists'');
}
我认为这是处理可以与我不使用的 firebase 一起使用的存储。
我也拿出来了:
let fbWorkerApp = firebase.apps.find(app => app.name === ''auth-worker'')
|| firebase.initializeApp(firebase.app().options,''auth-worker'');
fbWorkerAuth = fbWorkerApp.auth();
fbWorkerAuth.setPersistence(firebase.auth.Auth.Persistence.NONE); // disables caching of account credentials
并且只是使用“auth()”代替 fbWorkerAuth 因为我已经在这样做了:
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已通过
我已经使用了 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="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
import ''package:Flutter/material.dart'';
import ''../../generated/l10n.dart'';
import ''../models/user.dart'';
import ''../helpers/helper.dart'';
import ''../elements/BlockButtonWidget.dart'';
import ''../helpers/app_config.dart'' as config;
import ''package:mvc_pattern/mvc_pattern.dart'';
import ''../repository/user_repository.dart'' as repository;
import ''../repository/user_repository.dart'';
class SettingsController extends ControllerMVC {
GlobalKey<FormState> loginFormKey;
GlobalKey<ScaffoldState> scaffoldKey;
SettingsController() {
loginFormKey = new GlobalKey<FormState>();
this.scaffoldKey = new GlobalKey<ScaffoldState>();
}
void update(User user) async {
user.devicetoken = null;
repository.update(user).then((value) {
scaffoldKey?.currentState?.showSnackBar(SnackBar(
content: Text("Atualizado com Sucesso"),));
});
}
}
class ProfileSettingsDialog extends StatefulWidget {
final User user;
final VoidCallback onChanged;
ProfileSettingsDialog({Key key,@required this.user,this.onChanged}) : super(key: key);
@override
_ProfileSettingsDialogState createState() => _ProfileSettingsDialogState();
}
class _ProfileSettingsDialogState extends State<ProfileSettingsDialog> {
GlobalKey<FormState> _profileSettingsFormKey = new GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: Helper.of(context).onWillPop,child: Scaffold(
resizetoAvoidBottomPadding: false,body: Stack(
alignment: AlignmentDirectional.topCenter,children: <Widget>[
Positioned(
top: 0,child: Container(
width: config.App(context).appWidth(100),height: config.App(context).appHeight(29.5),decoration: Boxdecoration(color: Theme.of(context).accentColor),),Positioned(
top: config.App(context).appHeight(29.5) - 120,child: Container(
width: config.App(context).appWidth(84),child: Text(
S.of(context).lets_start_with_register,style: Theme.of(context).textTheme.headline2.merge(TextStyle(color: Theme.of(context).primaryColor)),Positioned(
top: config.App(context).appHeight(29.5) - 50,child: Container(
decoration: Boxdecoration(color: Theme.of(context).primaryColor,borderRadius: BorderRadius.all(Radius.circular(10)),BoxShadow: [
BoxShadow(
blurRadius: 50,color: Theme.of(context).hintColor.withOpacity(0.2),)
]),margin: EdgeInsets.symmetric(
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(
crossAxisAlignment: CrossAxisAlignment.stretch,mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[
TextFormField(
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(
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(
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(
labelText: "Endereço",hintText: ''johndoe@gmail.com'',prefixIcon: Icon(Icons.alternate_email,TextFormField(
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(
labelText: "Biografia",BlockButtonWidget(
text: Text(
S.of(context).register,style: TextStyle(color: Theme.of(context).primaryColor),color: Theme.of(context).accentColor,onpressed: () {
_profileSettingsFormKey.currentState.save();
widget.onChanged();
Navigator.pop(context);
update(currentUser.value);
//setState(() {});
},// widget.update(currentUser.value);
),SizedBox(height: 25),// FlatButton(
// onpressed: () {
// Navigator.of(context).pushNamed(''/MobiLeverification'');
// },// padding: EdgeInsets.symmetric(vertical: 14),// color: Theme.of(context).accentColor.withOpacity(0.1),// shape: StadiumBorder(),// child: Text(
// ''Register with Google'',// textAlign: TextAlign.start,// style: TextStyle(
// color: Theme.of(context).accentColor,// ),// ),// ),],);
}
Inputdecoration getInputdecoration({String hintText,String labelText}) {
return new Inputdecoration(
hintText: hintText,labelText: labelText,hintStyle: Theme.of(context).textTheme.bodyText2.merge(
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(
TextStyle(color: Theme.of(context).hintColor),);
}
}
解决方法
我看不到您的 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"的相关信息,请在本站寻找。
本文标签: