This package allows you to login with Google and/or Facebook api in AngularX (2+)
Install npm module :
npm install ngx-heyl-social-login
Import the module :
Open your app.module.ts
file and import the module like this :
import { SocialLoginModule } from "ngx-heyl-social-login";
@NgModule({
imports: [
...,
SocialLoginModule
]
})
Initialize Google and/or Facebook api in app.component.ts
:
Open your app.component.ts
and initialize Google and/or Facebook api :
constructor(private socialLoginService: SocialLoginService) {
// FacebookAppID : 15 digit number
this.socialLoginService.initFacebookProvider("FacebookAppID", "v2.9");
// GoogleAppId : numbers-numbersAndLetters
this.socialLoginService.initGoogleProvider("GoogleAppId");
}
<head>
HTML element you'll need to have. Don't put by yourself Google and Facebook sdk's, or Google's <meta>
elementNow yo can use the googleLogin and facebookLogin in your other components :
facebookLogin() {
this.socialLoginService.facebookLogin(socialUser => {
console.log(socialUser);
});
}
googleLogin() {
this.socialLoginService.googleLogin(socialUser => {
console.log(socialUser);
});
}