Angular 4 / 5 / 6 Social Login
Original repo is (https://github.com/abacritt/angularx-social-login/) Social login and authentication module for Angular 4 / 5 / 6. 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-with-fix
Import the module
In your AppModule
, import the SocialLoginModule
;; let config = id: GoogleLoginProviderPROVIDER_ID provider: "Google-OAuth-Client-Id" id: FacebookLoginProviderPROVIDER_ID provider: "Facebook-App-Id" id: LinkedInLoginProviderPROVIDER_ID provider: "LinkedIn-client-Id" false 'en_US' ; { return config;} @
Sign in and out users
;; @ implements OnInit { } : void thisauthService; : 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 }}
Specifying custom scope
const 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 ;
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