Angularfire 2 Error: The specified authentication provider is not enabled for this Firebase
Angularfire 2 Error: The specified authentication provider is not enabled for this Firebase
我正在使用 Ionic 2 和 angularfire 2 作为后端创建一个简单的示例身份验证应用程序,当我尝试创建新用户时它说:
EXCEPTION: Error: Uncaught (in promise): Error: The specified
authentication provider is not enabled for this Firebase.
但我已经在 firebase 控制台中启用了 firebase 身份验证:
app.ts
import {App, Platform} from 'ionic-angular';
import {StatusBar} from 'ionic-native';
import {HomePage} from './pages/home/home';
import { FIREBASE_PROVIDERS, defaultFirebase, firebaseAuthConfig, AuthProviders, AuthMethods } from 'angularfire2';
@App({
template: '<ion-nav [root]="rootPage"></ion-nav>',
providers: [
FIREBASE_PROVIDERS,
defaultFirebase('https://samplequizapp-50eb5.firebaseio.com'),
firebaseAuthConfig({
provider: AuthProviders.Password,
method: AuthMethods.Password
})
],
config: {} // http://ionicframework.com/docs/v2/api/config/Config/
})
export class MyApp {
rootPage: any = HomePage;
constructor(platform: Platform) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
StatusBar.styleDefault();
});
}
}
home.ts
import { Page } from 'ionic-angular';
import { AngularFire, FirebaseListObservable } from 'angularfire2';
import { OnInit } from '@angular/core'
@Page({
templateUrl: 'build/pages/home/home.html'
})
export class HomePage implements OnInit {
user: any = {};
data: FirebaseListObservable<any[]>;
constructor(private af: AngularFire) {
}
ngOnInit() {
this.data = this.af.database.list('/userId')
}
signUp(data) {
this.af.auth.createUser({
email: data.email,
password: data.password
})
}
}
我很确定我的代码没有问题:
当前版本 (2.4.2) 的 Firebase2 与 Firebase SDK v3 尚不兼容,使用新 Firebase 控制台创建的所有项目只能通过与 SDK v3 兼容的调用访问。
您想先在旧控制台中创建 Firebase 后端 www.firebase.com,然后再迁移到新控制台。
这在 angularfire2 github 的这个封闭问题中有记录:https://github.com/angular/angularfire2/issues/189
我正在使用 Ionic 2 和 angularfire 2 作为后端创建一个简单的示例身份验证应用程序,当我尝试创建新用户时它说:
EXCEPTION: Error: Uncaught (in promise): Error: The specified authentication provider is not enabled for this Firebase.
但我已经在 firebase 控制台中启用了 firebase 身份验证:
app.ts
import {App, Platform} from 'ionic-angular';
import {StatusBar} from 'ionic-native';
import {HomePage} from './pages/home/home';
import { FIREBASE_PROVIDERS, defaultFirebase, firebaseAuthConfig, AuthProviders, AuthMethods } from 'angularfire2';
@App({
template: '<ion-nav [root]="rootPage"></ion-nav>',
providers: [
FIREBASE_PROVIDERS,
defaultFirebase('https://samplequizapp-50eb5.firebaseio.com'),
firebaseAuthConfig({
provider: AuthProviders.Password,
method: AuthMethods.Password
})
],
config: {} // http://ionicframework.com/docs/v2/api/config/Config/
})
export class MyApp {
rootPage: any = HomePage;
constructor(platform: Platform) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
StatusBar.styleDefault();
});
}
}
home.ts
import { Page } from 'ionic-angular';
import { AngularFire, FirebaseListObservable } from 'angularfire2';
import { OnInit } from '@angular/core'
@Page({
templateUrl: 'build/pages/home/home.html'
})
export class HomePage implements OnInit {
user: any = {};
data: FirebaseListObservable<any[]>;
constructor(private af: AngularFire) {
}
ngOnInit() {
this.data = this.af.database.list('/userId')
}
signUp(data) {
this.af.auth.createUser({
email: data.email,
password: data.password
})
}
}
我很确定我的代码没有问题:
当前版本 (2.4.2) 的 Firebase2 与 Firebase SDK v3 尚不兼容,使用新 Firebase 控制台创建的所有项目只能通过与 SDK v3 兼容的调用访问。
您想先在旧控制台中创建 Firebase 后端 www.firebase.com,然后再迁移到新控制台。
这在 angularfire2 github 的这个封闭问题中有记录:https://github.com/angular/angularfire2/issues/189