Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including ng8-social-login with all npm packages installed. Try it out:

require("@angular/common/package.json"); // @angular/common is a peer dependency. require("@angular/core/package.json"); // @angular/core is a peer dependency. var ng8SocialLogin = require("ng8-social-login")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

ng8-social-login v8.0.1

This a simple, easy to use social login module.

NgxSocialLogin npm version

This module's intention is to provide an easy to use social login service, which can be integrated easily into any environment.

This project has been inspired by Angularx Social Login

Getting started

Install via npm/yarn

npm install --save ng8-social-login
yarn add ng8-social-login

Import the module

Import NgxSocialLoginModule into your Module. You can provide any configuration that is supported by Oauth providers.

Google:

  • https://developers.google.com/identity/sign-in/web/reference#gapiauth2clientconfig

Facebook:

  • https://developers.facebook.com/docs/javascript/reference/FB.init/v2.12
  • https://developers.facebook.com/docs/reference/javascript/FB.login/v2.12#params
@NgModule({
    declarations: [ ... ],
    imports: [
        ...
        NgxSocialLoginModule.init(
            {
                google: {
                    client_id: 'YOUR_CLIENT_ID'
                },
                facebook: {
                    initOptions: {
                        appId: 'YOUR_APP_ID'
                    }
                }
            }
        )
        ...
    ],
    providers: [ ... ]
})
export class AuthModule {
}

How to use

@Component({
  selector: 'app-login-page',
  templateUrl: './app-login-page.component.html',
  styleUrls: ['./app-login-page.component.css']
})
export class LoginPageComponent {

    constructor(private _service: SocialLoginService) {}

      loginWithFacebook(): void {
          this._service.login(Provider.FACEBOOK).subscribe(user => console.log(user));
      }

      loginWithGoogle(): void {
          this._service.login(Provider.GOOGLE).subscribe(user => console.log(user));
      }

      logout(): void {
          this._service.logout().subscribe({
               complete: ()=> console.log('Logout success'),
               error: err => console.log(err)
           });
      }

}

Demo

git clone https://github.com/wermerb/ngx-social-login.git
cd ng8-social-login
Add your Google and/or Facebook client id to AppModule's config
yarn / npm install
ng serve
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free