mr5*_*mr5 5 authentication firebase ionic-framework firebase-authentication
我正在尝试将"firebase phone authentication"与离子相结合.
但是,坚持一个问题.
我一直收到"找不到主机名匹配"的错误
.catch(function (error) {
console.log("error! : " + error);
});"
Run Code Online (Sandbox Code Playgroud)
login.ts(下)
import { Component } from '@angular/core';
import { IonicPage, NavController, AlertController } from 'ionic-angular';
import firebase from 'firebase';
@IonicPage()
@Component({
selector: 'page-login',
templateUrl: 'login.html',
})
export class LoginPage {
public recaptchaVerifier:firebase.auth.RecaptchaVerifier;
constructor(public navCtrl: NavController, public alertCtrl: AlertController) {}
ionViewDidLoad() {
this.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-
container');
}
signIn(phoneNumber: number){
const appVerifier = this.recaptchaVerifier;
const phoneNumberString = "+" + phoneNumber;
firebase.auth().signInWithPhoneNumber(phoneNumberString, appVerifier)
.then( confirmationResult => {
let prompt = this.alertCtrl.create({
title: 'Enter the Confirmation code',
inputs: [{ name: 'confirmationCode', placeholder: 'Confirmation Code' }],
buttons: [
{ text: 'Cancel',
handler: data => { console.log('Cancel clicked'); }
},
{ text: 'Send',
handler: data => {
confirmationResult.confirm(data.confirmationCode)
.then(function (result) {
}).catch(function (error) {
});
}
}
]
});
prompt.present();
})
.catch(function (error) {
console.log("error! : " + error); // <------------The place that informs this error.
});
}
}
Run Code Online (Sandbox Code Playgroud)
reCAPTCHA解决后不久发生此错误
为什么会这样?
- 初始化Firebase
--login.html
Har*_*esh 18
当您在未经ssl认证的域中托管您的应用时,可能会发生此错误.然后,您必须在firebase控制台中将您的域列入白名单.
转到Firebase Console -> Authentication -> sign-in-method -> Authorized Domains并添加您的域名.
默认情况下localhost,任何https://域都列入白名单.
发生此错误的原因是,当Google在Number上发送otp时,它与您的网站网址匹配,而您的Firebase身份验证url与您的域或站点地址相匹配,那么它将向您发送otp,否则会发生错误。
要解决该错误,请转到Firebase控制台。
转到Firebase控制台。
单击身份验证。
单击登录方法。
向下滚动并检查授权域。
将您的站点地址添加到实现电话认证的位置。
| 归档时间: |
|
| 查看次数: |
4151 次 |
| 最近记录: |