auth-social
v1.0.4
Published
A NodeJS/Typescript module for web application that supports authentication with Google and Facebook and can be extended to other provider.
Downloads
14
Maintainers
Readme
auth-social
A Node.js/Typescript module for web application that supports authentication with Google and Facebook and can be extended to other providers also.
Installation
npm install auth-social --save
yarn add auth-social
bower install auth-social --save
Usage
TypeScript
Create 'AuthConfig' configutation object for AuthService, responsible for handling all authorization activity like sign-in or sign-out
import {AuthService, FacebookLoginProvider, GoogleLoginProvider, AuthConfig } from 'auth-social';
private config:AuthConfig = new AuthConfig([
{
id: GoogleLoginProvider.PROVIDER_ID,
provider: new GoogleLoginProvider("<your-app-google-api-key>","<your-app-google-client_id>")
},
{
id: FacebookLoginProvider.PROVIDER_ID,
provider: new FacebookLoginProvider("<your-facebook-app_id>")
}
]);
private authService:AuthService = new AuthService(config);
Perform user sign-in using Facebook
import { AuthService, FacebookLoginProvider, User } from 'auth-social';
this.authService.signIn(FacebookLoginProvider.PROVIDER_ID).then((user:User) => {
console.log(user);
//User login successfuly
}, (error:any)=>{
//error occured while user sign-in
});
Perform user sign-in using Google
import { AuthService, GoogleLoginProvider, User } from 'auth-social';
this.authService.signIn(GoogleLoginProvider.PROVIDER_ID).then((user:User) => {
console.log(user);
//User login successfuly
}, (error:any)=>{
//error occured while user sign-in
});
Perform user sign-out
import { AuthService } from 'auth-social';
this.authService.signOut().then(() => {
//User log-off successfully
}, (error:any)=>{
//error occured while user signout
});
Javascript
Create 'AuthConfig' configutation object for AuthService, responsible for handling all authorization activity like sign-in or sign-out
var auth = require('auth-social');
var config = new auth.AuthConfig([
{
id: GoogleLoginProvider.PROVIDER_ID,
provider: new auth.GoogleLoginProvider("<your-app-google-api-key>","<your-app-google-client_id>")
},
{
id: FacebookLoginProvider.PROVIDER_ID,
provider: new auth.FacebookLoginProvider("<your-facebook-app_id>")
}
]);
var authService = new auth.AuthService(config);
Perform user sign-in using Facebook
var auth = require('auth-social');
authService.signIn(auth.FacebookLoginProvider.PROVIDER_ID).then((user) => {
console.log(user);
//User login successfuly
}, (error:any)=>{
//error occured while user sign-in
});
Perform user sign-in using Google
var auth = require('auth-social');
authService.signIn(auth.GoogleLoginProvider.PROVIDER_ID).then((user) => {
console.log(user);
//User login successfuly
}, (error:any)=>{
//error occured while user sign-in
});
Perform user sign-out
var auth = require('auth-social');
authService.signOut().then(() => {
//User log-off successfully
}, (error:any)=>{
//error occured while user signout
});
Support
You can directly send any bug/issue or suggestion to my personal email id: [email protected].