Skip to content
/ SAuth Public

SAuth is a social authentification module that works with access token

Notifications You must be signed in to change notification settings

SamiAyed/SAuth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SAuth

SAuth is a social authentification module that works with access token

  • Supports Facebook, Twitter and Google
  • Unify all drivers in one module
  • Easy api

Usage

Install the dependency

Npm

npm install sauth-token

Yarn

yarn add sauth-token

Setup

const SAuth = require('sauth-token');
const sAuth = new SAuth({
  facebook: {
    fields: ['id', 'first_name', 'last_name', 'birthday', 'email', 'picture']
  },
  twitter: {
    consumer_key: process.env.TWITTER_CONSUMER_KEY,
    consumer_secret: process.env.TWITTER_CONSUMER_SECRET
  },
  google: { // Not Required
      
  }
})

Facebook

Promise

sAuth.driver('facebook')
    .getUserByToken(<access_token>)
    .then(user => {
      console.log(user);
    })
    .catch(error => {
        console.error(error)
    });

Async/Await

try {
    const user = await sAuth.driver('facebook')
        .getUserByToken(<access_token>);

    console.log(user);
} catch(error) {
    console.error(error)
}

Twitter

Promise

sAuth.driver('twitter')
    .getUserByToken(<access_token>, <access_secret>)
    .then(user => {
      console.log(user);
    })
    .catch(error => {
        console.error(error)
    });

Async/Await

try {
    const user = await sAuth.driver('twitter')
        .getUserByToken(<access_token>, <access_secret>);

    console.log(user);
} catch(error) {
    console.error(error)
}

Google

Promise

sAuth.driver('google')
    .getUserByToken(<access_token>)
    .then(user => {
      console.log(user);
    })
    .catch(error => {
        console.error(error)
    });

Async/Await

try {
    const user = await sAuth.driver('google')
        .getUserByToken(<access_token>);

    console.log(user);
} catch(error) {
    console.error(error)
}

Development

Want to contribute? Great!

  • Clone the repository
  • Create a new branch
  • Make a change in your files and create your test files

Open your favorite Terminal and run the test command.

$ yarn run test

Todos

  • Add support for other drivers
  • Add other export methods

Author

Sami Ayed - Software Engineer and Tech Lead Contact: m.ayed.sami@gmail.com

License

MIT

Free Software, Hell Yeah!

About

SAuth is a social authentification module that works with access token

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published