我正在使用 github 上的基本 firebase 入门套件来测试 firebase 身份验证部分。下面是 firebase 入门工具包链接,其中介绍了使用基本 react 本机应用程序设置 firebase 的步骤。
https://github.com/invertase/react-native-firebase-starter
App.js 已被替换为具有非常简单的表单,该表单将电话号码作为输入并调用 firebase auth API signInWithPhoneNumber() 以发送文本消息。下面是相关代码
具有所有相关配置详细信息的 Firebase intilization
firebase.initializeApp({
apiKey: '',
authDomain: '<>',
databaseURL: '<>',
projectId: '<>',
storageBucket: '<>',
messagingSenderId: '<>'
});
验证 API 调用
firebase.auth().signInWithPhoneNumber(phoneNumber)
.then(confirmResult => console.log(confirmResult))
.catch(error => this.setState({message: Sign In With Phone Number Error: ${error.message}}));
上述 API 调用 (2) 导致 400 错误请求。catlog 中看到的日志快照如下
05-07 14:04:21.643 3509 6366 W FirebaseAuth: [PhoneVerificationSession] PhoneVerificationSession constructor
05-07 14:04:21.648 3509 4952 W FirebaseAuth: [PhoneNumberAuthPostProcessor] postProcess starts
05-07 14:04:22.284 3509 13712 E Volley : [237] BasicNetwork.performRequest: Unexpected response code 400 for https://www.googleapis.com/identitytoolkit/v3/relyingparty/sendVerificationCode?alt=proto&key=
05-07 14:04:22.286 3509 6366 W FirebaseAuth: [PhoneVerificationSession] onFailure
05-07 14:04:22.451 3509 4952 W FirebaseAuth: [PhoneNumberAuthPostProcessor] postProcess ends
不确定 400 错误请求的原因是什么。任何帮助将不胜感激。
如果需要更多信息来理解该问题,请告诉我。