如何在 angular fire auth 中使用 provider 进行身份验证?
我正在尝试使用身份验证提供程序对用户进行身份验证。
这是所有教程的建议,
使用 import { auth } from 'firebase/app';
但我收到错误:
'"firebase/app"' has no exported member 'auth'
代码如下:
import { Injectable } from '@angular/core';
import { auth } from 'firebase/app';
import { AngularFireAuth } from "@angular/fire/auth";
@Injectable({
providedIn: 'root'
})
export class AuthService {
constructor(
public afAuth: AngularFireAuth, // Inject Firebase auth service
) { }
// Sign in with Facebook
FacebookAuth() {
return this.AuthLogin(new auth.FacebookAuthProvider());
}
// Auth logic to run auth providers
AuthLogin(provider) {
return this.afAuth.auth.signInWithPopup(provider)
.then((result) => {
console.log('You have been successfully logged in!')
}).catch((error) => {
console.log(error)
})
}
}
但是当我尝试导入此 import { auth } from 'firebase/app';
时,编译器会抛出错误,指出该模块没有名为 auth 的导出成员。我可以知道如何解决吗?
或者除了使用任何第三方库(如 angularx-social-login
或 ngx-auth-firebaseui