npm install --save angularx-social-login
const config = new AuthServiceConfig([
{
id: FacebookLoginProvider.PROVIDER_ID,
provider: new FacebookLoginProvider('2203659926599837')
}
]);
export function provideConfig() {
return config;
}
providers: [
{
provide: AuthServiceConfig,
useFactory: provideConfig
}
],
import {
MatIconModule,
MatButtonModule,
MatCardModule } from '@angular/material';
imports: [
...
MatIconModule,
MatButtonModule,
MatCardModule
],
import { AuthService, FacebookLoginProvider, SocialUser } from 'angularx-social-login';
export class AppComponent implements OnInit {
...
}
signInWithFB(): void {
this.authService.signIn(FacebookLoginProvider.PROVIDER_ID);
}
signOut(): void {
this.authService.signOut();
}
ngOnInit() {
this.authService.authState.subscribe((user) => {
this.user = user;
this.loggedIn = (user != null);
console.log(this.user);
});
}