forked from Concorda/seneca-linkedin-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinkedin-auth.js
33 lines (28 loc) · 913 Bytes
/
linkedin-auth.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
var LinkedinStrategy = require('passport-linkedin').Strategy
module.exports = function (options) {
var seneca = this
var authPlugin = new LinkedinStrategy({
consumerKey: options.consumerKey,
consumerSecret: options.consumerSecret,
callbackURL: options.urlhost + '/auth/linkedin/callback',
profileFields: ['id', 'first-name', 'last-name', 'email-address', 'headline']
},
function (token, tokenSecret, profile, done) {
var data = {
nick: profile.displayName,
name: profile.displayName,
identifier: '' + profile.id,
credentials: {
token: token,
secret: tokenSecret},
userdata: profile,
when: new Date().toISOString()
}
done(null, data)
}
)
seneca.act({role: 'auth', cmd: 'register_service', service: 'linkedin', plugin: authPlugin, conf: options})
return {
name: 'linkedin-auth'
}
}