I have an issue, implementing "Firebase authentication with Google" in my angular 8 app. It seems that "auth" property is not at all supported working since @angular/fire's version 6.0.0 !!!
Here are my dependencies :
"@angular/cdk": "^11.0.1", "@angular/fire": "^6.1.4", "firebase": "^8.1.2",
My Login service : (login.service.ts) :
import { Injectable } from '@angular/core';
// import { auth } from 'firebase/app';
import { AngularFireAuth } from "@angular/fire/auth";
@Injectable({
providedIn: 'root'
})
export class LoginService {
constructor(
public afAuth: AngularFireAuth, // Inject Firebase auth service
) { }
// Sign in with Google
GoogleAuth() {
return this.AuthLogin(new auth.GoogleAuthProvider());
}
// Auth logic to run auth providers
AuthLogin(provider: any) {
return this.afAuth.signInWithPopup(provider)
.then((result: any) => {
console.log('You have been successfully logged in!')
}).catch((error: any) => {
console.log(error)
})
}
}
My login.component.ts :
import { Component, OnInit } from '@angular/core';
import { LoginService } from '../../services/login.service';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {
constructor(public loginService: LoginService) { }
ngOnInit() { }
}
My login.component.html :
<button mat-raised-button (click)="LoginService.GoogleAuth()" color="primary" >Login with Google</button>
Can someone help me to solve this issue ? Thanks for you help