forked from hapijs/bell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfacebook.js
executable file
·53 lines (43 loc) · 1.51 KB
/
facebook.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
'use strict';
// Load modules
const Hapi = require('hapi');
const Hoek = require('hoek');
const Bell = require('../');
const server = new Hapi.Server();
server.connection({ host: 'localhost', port: 3456 });
server.register(Bell, (err) => {
Hoek.assert(!err, err);
server.auth.strategy('facebook', 'bell', {
provider: 'facebook',
password: 'cookie_encryption_password_secure',
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((err) => {
Hoek.assert(!err, err);
console.log('Server started at:', server.info.uri);
});
});