Angularfire 2 Error: The specified authentication provider is not enabled for this Firebase

大憨熊 提交于 2019-12-12 03:36:28

问题


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:


回答1:


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



来源:https://stackoverflow.com/questions/37501384/firebase-returns-authentication-disabled

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!