2017-04-21 159 views
0

我在控制檯通過谷歌啓用驗證返回400: enter image description here火力地堡認證與angularfire2

登錄代碼:

import { Component, OnInit } from '@angular/core'; 
import { AngularFire, AuthProviders } from 'angularfire2'; 

@Component({ 
    selector: 'app-login', 
    templateUrl: './login.component.html', 
    styleUrls: ['./login.component.css'] 
}) 
export class LoginComponent implements OnInit { 
    user = {}; 
    constructor(public af: AngularFire) { 
    this.af.auth.subscribe(user => { 
     if(user) { 
     // user logged in 
     this.user = user; 
     } 
     else { 
     // user not logged in 
     this.user = {}; 
     } 
    }); 
    } 

    login() { 
    this.af.auth.login({ 
     provider: AuthProviders.Google 
    }); 
    } 

    ngOnInit() { 
    } 

} 

this.af.auth.login()調用產生下面的錯誤。

www.googleapis.com/identitytoolkit/v3/relyingparty/signupNewUser?key=AIzaSyDyJQVTQI-a-eW2iM70RXAcVHKDb0NP1Ek:1 POST 

https://www.googleapis.com/identitytoolkit/v3/relyingparty/signupNewUser?key=AIzaSyDyJQVTQI-a-eW2iM70RXAcVHKDb0NP1Ek 400() 
core.es5.js:1084ERROR Error: Uncaught (in promise): Error: The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section. 
    at resolvePromise (zone.js:712) [angular] 
    at resolvePromise (zone.js:683) [angular] 
    at polyfills.bundle.js:3492:17 [angular] 
    at Object.onInvokeTask (core.es5.js:4116) [angular] 
    at ZoneDelegate.invokeTask (zone.js:397) [angular] 
    at Zone.runTask (zone.js:165) [<root> => angular] 
    at drainMicroTaskQueue (zone.js:593) [<root>] 
    at XMLHttpRequest.ZoneTask.invoke (zone.js:464) [<root>] 

谷歌搜索發現,這是一個問題,當火力地堡SDK是< 3.我使用的是最新的angularfire2的版本,所以這不應該是一個問題。

回答

1

如果您在angularFire2中重寫登錄配置,則應設置方法和提供者。嘗試像這樣登錄:

import { AuthMethods, AuthProviders } from 'angularfire2'; 

    login() { 
    this.af.auth.login({ 
     method: AuthMethods.Redirect, 
     provider: AuthProviders.Google 
    }); 
    } 
+0

非常感謝!我搜索了Google,並在angularfire2 Gitter中掛了出去,並且無法在任何地方找到它。 – Lunchbox