Skip to content

Instantly share code, notes, and snippets.

@sebabelmar
Created July 6, 2016 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebabelmar/3abf03df219952af93ec60504587b616 to your computer and use it in GitHub Desktop.
Save sebabelmar/3abf03df219952af93ec60504587b616 to your computer and use it in GitHub Desktop.
Passport Instagram Strategy for meanjs.or
'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