Angular 4 / 5 Social Login
Social login and authentication module for Angular 4 / 5. Supports authentication with Google and Facebook. Can be extended to other providers also.
Check out the demo.
Getting started
Install via npm
npm install --save angularx-social-login
Import the module
In your AppModule
, import the SocialLoginModule
; // OPTIONAL: custom config for loginconst fbLoginOptions: LoginOpt = scope: 'pages_messaging,pages_messaging_subscriptions,email,pages_show_list,manage_pages' return_scopes: true enable_profile_selector: true; // https://developers.facebook.com/docs/reference/javascript/FB.login/v2.11 const googleLoginOptions: LoginOpt = scope: 'profile email'; // https://developers.google.com/api-client-library/javascript/reference/referencedocs#gapiauth2clientconfig let config = id: GoogleLoginProviderPROVIDER_ID provider: "Google-OAuth-Client-Id" googleLoginOptions id: FacebookLoginProviderPROVIDER_ID provider: "Facebook-App-Id" fbLoginOptions ; @
Sign in and out users
;; @ implements OnInit { } : void thisauthService; : void thisauthService; : void thisauthService;
Subscribe to the authentication state
You are notified when user logs in or logs out. You receive a SocialUser
object when the user logs in and a null
when the user logs out. SocialUser
object contains basic user information such as name, email, photo URL, etc.
;; @ implements OnInit private user: SocialUser; private loggedIn: boolean; { } { thisauthServiceauthState; }
Display the user information
{{ user.name }} {{ user.email }}
Building with AoT
If you are facing issue in building your app with AoT, check this document.
Running the demo app
cd demonpm installng serve