social-login-oauth
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Social Login for all Typescript Projects like Angular 2 & above, reactJS, VueJS etc ..,

Social login and authentication which supports authentication with Google and Facebook platforms.

Getting started

Install via npm

npm install social-login-oauth --save 

Usage

 
import { GoogleService, FacebookService } from "social-login-oauth";
 
@Component({
  selector: 'app-demo',
  templateUrl: './demo.component.html',
  styleUrls: ['./demo.component.css']
})
export class DemoComponent {
 
  constructor() { }
 
  googleSignIn() {
    GoogleService.signIn(gClientid)
  }
  
  getGoogleLoginStatus(){
    GoogleService.getLoginStatus() 
  }
 
  facebookSignIn(): void {
    FacebookService.signIn(facebookID)
  } 
  
  getFacebookLoginStatus(){
    FacebookService.getLoginStatus()
  }
 
  googleSignOut(): void {
    //if revoke is true, it will be disconnected instead of signout.
    GoogleService.signOut(revoke);
  }
  
  facebookSignOut(): void {
    FacebookService.signOut();
  }
 
}

Possible fields get after the Social login.

    id: string;
    email: string;
    name: string;
    photoUrl: string;
    firstName: string;
    lastName: string;
    authToken: string;
    idToken?: string;
    authorizationCode?: string;
    provider?: string;
    facebook?: any;
    linkedIn?: any;

Specifying custom scope

For Google

 
const googleLoginOptions: LoginOpt = {
  scope: 'profile email'
}; // https://developers.google.com/api-client-library/javascript/reference/referencedocs#gapiauth2clientconfig
 
GoogleService.signIn(gClientid,googleLoginOptions)

For Facebook

 
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
 
FacebookService.signIn(facebookID,fbLoginOptions)

License

MIT

Package Sidebar

Install

npm i social-login-oauth

Weekly Downloads

328

Version

1.0.4

License

MIT

Unpacked Size

57.8 kB

Total Files

34

Last publish

Collaborators

  • dxmari