Skip to content

Instantly share code, notes, and snippets.

@ivportilla
Created January 6, 2017 16:27
Show Gist options
  • Save ivportilla/1c91293b7c8f52306c536f615096e778 to your computer and use it in GitHub Desktop.
Save ivportilla/1c91293b7c8f52306c536f615096e778 to your computer and use it in GitHub Desktop.
const auth = require('feathers-authentication');
const FacebookTokenStrategy = require('passport-facebook-token');
// const GooglePlusTokenStrategy = require('passport-google-plus-token');
const local = require('feathers-authentication-local');
const jwt = require('feathers-authentication-jwt');
const oauth2 = require('feathers-authentication-oauth2');
module.exports = function () {
const app = this;
const config = app.get('auth');
app.configure(auth(config))
.configure(local())
.configure(jwt())
.configure(oauth2({
name: 'facebook',
Strategy: FacebookTokenStrategy,
}));
/* .configure(oauth2({
name: 'google',
Strategy: GooglePlusTokenStrategy,
}));*/
app.service('authentication').hooks({
before: {
create: [
auth.hooks.authenticate(['local', 'facebook', 'google']),
],
remove: [
auth.hooks.authenticate('jwt'),
],
},
});
};
{
"host": "localhost",
"port": 3030,
"mongodb": "mongodb://localhost:27017/db",
"public": "../public/",
"auth": {
"secret": "Your secret",
"facebook": {
"clientID": "XXXXX",
"clientSecret": "ZZZZZ"
},
"google": {
"clientID": "",
"clientSecret": ""
}
}
}
POST /authentication
body: {
"access_token": "kjbILH7hl8hpbyPBUP9...",
"strategy": "facebook"
}
RESPONSE:
{
"access_token": "....."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment