Created
July 6, 2016 07:50
-
-
Save sebabelmar/3abf03df219952af93ec60504587b616 to your computer and use it in GitHub Desktop.
Passport Instagram Strategy for meanjs.or
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/** | |
* Module dependencies. | |
*/ | |
var passport = require('passport'), | |
InstagramStrategy = require('passport-instagram').Strategy, | |
users = require('../../controllers/users.server.controller'); | |
module.exports = function(config) { | |
// Use instagram strategy | |
passport.use(new InstagramStrategy({ | |
clientID: config.instagram.clientID, | |
clientSecret: config.instagram.clientSecret, | |
callbackURL: config.instagram.callbackURL, | |
passReqToCallback: true | |
}, | |
function(req, accessToken, refreshToken, profile, done) { | |
// Set the provider data and include tokens | |
var providerData = profile._json.data; | |
providerData.accessToken = accessToken; | |
providerData.refreshToken = refreshToken; | |
// Create the user OAuth profile | |
var providerUserProfile = { | |
displayName: profile.displayName, | |
username: profile.username, | |
provider: 'instagram', | |
providerIdentifierField: 'id', | |
providerData: providerData | |
}; | |
// Save the user OAuth profile | |
users.saveOAuthUserProfile(req, providerUserProfile, done); | |
})); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment