Angularfire 2错误:指定的身份验证提供程序未启用此Firebase [英] Angularfire 2 Error: The specified authentication provider is not enabled for this Firebase

查看:161
本文介绍了Angularfire 2错误:指定的身份验证提供程序未启用此Firebase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





例外:错误:未捕获(承诺):错误:指定的
身份验证提供程序未启用此Firebase。但是我已经在Firebase控制台中启用了Firebase身份验证:



app.ts

 从'ionic-angular'导入{App,Platform}; 
从'ionic-native'导入{StatusBar};
从'./pages/home/home'中导入{HomePage};
从'angularfire2'导入{FIREBASE_PROVIDERS,defaultFirebase,firebaseAuthConfig,AuthProviders,AuthMethods};
$ b @App({
template:'< ion-nav [root] =rootPage>< / ion-nav>',
providers:[
FIREBASE_PROVIDERS,
defaultFirebase('https://samplequizapp-50eb5.firebaseio.com'),
firebaseAuthConfig({
提供者:AuthProviders.Password,
方法:AuthMethods .Password
})
],
config:{} // http://ionicframework.com/docs/v2/api/config/Config/
})
导出类MyApp {
rootPage:any = HomePage;

构造函数(platform:Platform){
platform.ready()。then(()=> {
//好的,所以平台已经准备就绪,我们的插件是
//在这里,你可以做任何你可能需要的更高级别的本地事物
StatusBar.styleDefault();
});


$ / code $ / pre
$ b

home.ts

 从'ionic-angular'导入{Page} 
从'angularfire2'导入{AngularFire,FirebaseListObservable};
从'@ angular / core'导入{OnInit}

@Page({
templateUrl:'build / pages / home / home.html'
})
export class HomePage实现OnInit {
user:any = {};
data:FirebaseListObservable< any []>;

构造函数(private af:AngularFire){
}

ngOnInit(){
this.data = this.af.database.list(' / userId')
}

signUp(data){
this.af.auth.createUser({
email:data.email,
password :data.password
))
}

}



Firebase2在其当前的版本(2.4.2)中提供了一个新的版本,尚未与Firebase SDK v3兼容,所有使用新版Firebase控制台创建的项目只能通过SDK v3兼容的调用进行访问。



您要创建Firebase后端先在旧版控制台 www.firebase.com 中,然后迁移到新的控制台。



这是在angularfire2 github的这个封闭的问题中记录的: https://github.com/ang ular / angularfire2 / issues / 189


I am creating a simple sample auth app with Ionic 2 and angularfire 2 as backend, when i try to create new user it says:

EXCEPTION: Error: Uncaught (in promise): Error: The specified authentication provider is not enabled for this Firebase.

But i already enabled firebase authentication in firebase console:

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
    })
  }

}

I am pretty sure there is nothing wrong with my code:

解决方案

Firebase2 in its current version (2.4.2) is not yet compatible with Firebase SDK v3, and all projects created with the new Firebase console are only accessible with calls comaptible with SDK v3.

You want to create your Firebase backend in the legacy console www.firebase.com first, and then migrate to the new console.

This is documented in this closed issue of the angularfire2 github: https://github.com/angular/angularfire2/issues/189

这篇关于Angularfire 2错误:指定的身份验证提供程序未启用此Firebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆