SAuth is a social authentification module that works with access token
- Supports Facebook, Twitter and Google
- Unify all drivers in one module
- Easy api
Install the dependency
npm install sauth-token
yarn add sauth-token
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
}
})
sAuth.driver('facebook')
.getUserByToken(<access_token>)
.then(user => {
console.log(user);
})
.catch(error => {
console.error(error)
});
try {
const user = await sAuth.driver('facebook')
.getUserByToken(<access_token>);
console.log(user);
} catch(error) {
console.error(error)
}
sAuth.driver('twitter')
.getUserByToken(<access_token>, <access_secret>)
.then(user => {
console.log(user);
})
.catch(error => {
console.error(error)
});
try {
const user = await sAuth.driver('twitter')
.getUserByToken(<access_token>, <access_secret>);
console.log(user);
} catch(error) {
console.error(error)
}
sAuth.driver('google')
.getUserByToken(<access_token>)
.then(user => {
console.log(user);
})
.catch(error => {
console.error(error)
});
try {
const user = await sAuth.driver('google')
.getUserByToken(<access_token>);
console.log(user);
} catch(error) {
console.error(error)
}
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
- Add support for other drivers
- Add other export methods
Sami Ayed - Software Engineer and Tech Lead Contact: m.ayed.sami@gmail.com
MIT
Free Software, Hell Yeah!