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

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

问题描述

我正在创建一个简单的示例身份验证应用程序,使用 Ionic 2 和 angularfire 2 作为后端,当我尝试创建新用户时,它说:

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:

例外:错误:未捕获(承诺):错误:指定的此 Firebase 未启用身份验证提供程序.

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

但我已经在 firebase 控制台中启用了 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 当前版本 (2.4.2) 尚不兼容 Firebase SDK v3,所有使用新 Firebase 控制台创建的项目只能通过调用访问与 SDK v3 兼容.

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.

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

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

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

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

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

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