Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facebook Provider: Fix expiresIn, add example, backwards compatibility #120

Merged
merged 1 commit into from
Jul 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions examples/facebook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Load modules

var Hapi = require('hapi');
var Bell = require('../');


var server = new Hapi.Server();
server.connection({ host: 'localhost', port: 3456});

server.register(Bell, function (err) {

server.auth.strategy('facebook', 'bell', {
provider: 'facebook',
password: 'password',
isSecure: false,
// You'll need to go to https://developers.facebook.com/ and set up a
// Website application to get started
// Once you create your app, fill out Settings and set the App Domains
// Under Settings >> Advanced, set the Valid OAuth redirect URIs to include http://<yourdomain.com>/bell/door
// and enable Client OAuth Login
clientId: '',
clientSecret: '',
location: server.info.uri
});

server.route({
method: '*',
path: '/bell/door',
config: {
auth: {
strategy: 'facebook',
mode: 'try'
},
handler: function (request, reply) {

if (!request.auth.isAuthenticated) {
return reply('Authentication failed due to: ' + request.auth.error.message);
}
reply('<pre>' + JSON.stringify(request.auth.credentials, null, 4) + '</pre>');
}
}
});

server.start(function (err) {

console.log('Server started at:', server.info.uri);
});
});
4 changes: 2 additions & 2 deletions lib/providers/facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ exports = module.exports = function (options) {
protocol: 'oauth2',
useParamsAuth: true,
auth: 'https://www.facebook.com/v2.3/dialog/oauth',
token: 'https://graph.facebook.com/oauth/access_token',
token: 'https://graph.facebook.com/v2.3/oauth/access_token',
scope: ['email'],
scopeSeparator: ',',
profile: function (credentials, params, get, callback) {

var query = {
appsecret_proof: Crypto.createHmac('sha256', this.clientSecret).update(credentials.token).digest('hex'),
fields: 'id,name,email,first_name,last_name,middle_name'
fields: 'id,name,email,first_name,last_name,middle_name,gender,link,locale,timezone,updated_time,verified'
};

get('https://graph.facebook.com/v2.3/me', query, function (profile) {
Expand Down