How to use the passport-github2.Strategy function in passport-github2

To help you get started, we’ve selected a few passport-github2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BCDevExchange / BCDevExchange-app / server / app.js View on Github external
// set up db connection
  var db = require('./models/db')

  console.log('NODE_ENV: ' + config.util.getEnv('NODE_ENV'))

  // Passport session setup
  passport.serializeUser(function (user, done) {
    done(null, user)
  })

  passport.deserializeUser(function (user, done) {
    done(null, user)
  })

  // use GitHubStrategy with Passport
  passport.use(new GitHubStrategy({
    clientID: (process.env.GH_CLIENT_ID || config.github.clientID),
    clientSecret: (process.env.GH_CLIENT_SECRET || config.github.clientSecret),
    callbackURL: config.github.callbackURL,
    passReqToCallback: true
  },
  function (req, accessToken, refreshToken, extProfile, done) {
    auth.passportStrategySetup(req, accessToken, refreshToken, extProfile, done)
  }
  ))


  // use LinkedInStrategy with Passport
  passport.use(new LinkedInStrategy({
    clientID: (process.env.LI_CLIENT_ID || config.linkedin.clientID),
    clientSecret: (process.env.LI_CLIENT_SECRET || config.linkedin.clientSecret),
    callbackURL: config.linkedin.callbackURL,
github BCDevExchange / BCDevExchange-app / server / app.js View on Github external
// set up db connection
  var db = require('./models/db')

  console.log('NODE_ENV: ' + config.util.getEnv('NODE_ENV'))

  // Passport session setup
  passport.serializeUser(function (user, done) {
    done(null, user)
  })

  passport.deserializeUser(function (user, done) {
    done(null, user)
  })

  // use GitHubStrategy with Passport
  passport.use(new GitHubStrategy({
      clientID: (process.env.GH_CLIENT_ID || config.github.clientID),
      clientSecret: (process.env.GH_CLIENT_SECRET || config.github.clientSecret),
      callbackURL: config.github.callbackURL,
      passReqToCallback: true
    },
    function (req, accessToken, refreshToken, extProfile, done) {
      passportStrategySetup(req, accessToken, refreshToken, extProfile, done)
    }
  ))


  // use LinkedInStrategy with Passport
  passport.use(new LinkedInStrategy({
    clientID: (process.env.LI_CLIENT_ID || config.linkedin.clientID),
    clientSecret: (process.env.LI_CLIENT_SECRET || config.linkedin.clientSecret),
    callbackURL: config.linkedin.callbackURL,
github BCDevExchange / BCDevExchange-app / server.js View on Github external
// set up db connection
    var db = require('./app/models/db');

    console.log('NODE_ENV: ' + config.util.getEnv('NODE_ENV'));

    // Passport session setup
    passport.serializeUser(function (user, done) {
        done(null, user);
    });

    passport.deserializeUser(function (user, done) {
        done(null, user);
    });

    // use GitHubStrategy with Passport
    passport.use(new GitHubStrategy({
            clientID: (process.env.GH_CLIENT_ID || config.github.clientID),
            clientSecret: (process.env.GH_CLIENT_SECRET || config.github.clientSecret),
            callbackURL: config.github.callbackURL,
            passReqToCallback: true
        },
        function (req, accessToken, refreshToken, extProfile, done) {
            passportStrategySetup(req, accessToken, refreshToken, extProfile, done);
        }
    ));


    // use LinkedInStrategy with Passport
    passport.use(new LinkedInStrategy({
            clientID: (process.env.LI_CLIENT_ID || config.linkedin.clientID),
            clientSecret: (process.env.LI_CLIENT_SECRET || config.linkedin.clientSecret),
            callbackURL: config.linkedin.callbackURL,
github drewwmercer / developer-ocs / controllers / loginController.js View on Github external
return done(err);
                  });
              }
            })
            .catch(err => {
              return done(err);
            });
        });
      }
    )
  );

  // Use the Github Strategy within Passport.

  passport.use(
    new GitHubStrategy(
      {
        clientID: '49b48c42021706f2c9cf',
        clientSecret: 'e54641680cd932ed79f9ff7cdac450f5caf78277',
        callbackURL: githubCallBackURL
      },
      (accessToken, refreshToken, profile, done) => {
        console.log(profile);
        process.nextTick(() => {
          db.User
            .findOne({
              where: {
                github_id: profile.id
              }
            })
            .then(dbUserResults => {
              console.log(dbUserResults);
github frontendbr / eventos-api / src / middleware / passport-middleware / index.js View on Github external
//   and deserialized.
  passport.serializeUser((user, done) => {
    // TODO tratar no firebase?
    done(null, user)
  })

  passport.deserializeUser((obj, done) => {
    // TODO tratar no firebase?
    done(null, obj)
  })

  // Use the GitHubStrategy within Passport.
  //   Strategies in Passport require a `verify` function, which accept
  //   credentials (in this case, an accessToken, refreshToken, and GitHub
  //   profile), and invoke a callback with a user object.
  passport.use(new Strategy({
    clientID: GITHUB_CLIENT_ID,
    clientSecret: GITHUB_CLIENT_SECRET,
    callbackURL: CALLBACK_URL
  }, (accessToken, refreshToken, profile, done) => {
    const credential = firebase.auth.GithubAuthProvider.credential(accessToken)

    profile.accessToken = accessToken
    profile.credential = credential

    // asynchronous verification, for effect...
    process.nextTick(() => {
      // To keep the example simple, the user's GitHub profile is returned to
      // represent the logged-in user.  In a typical application, you would want
      // to associate the GitHub account with a user record in your database,
      // and return that user instead.
      return done(null, profile)
github Shikkic / git-dash / server / config / passport.js View on Github external
// required for persistent login sessions
    // passport needs ability to serialize and unserialize users out of session

    // used to serialize the user for the session
    passport.serializeUser(function(user, done) {
        done(null, user.id);
    });

    // used to deserialize the user
    passport.deserializeUser(function(id, done) {
        User.findById(id, function(err, user) {
            done(err, user);
        });
    });

    passport.use(new GithubStrategy({
        clientID: GITHUB_CLIENT_ID,
        clientSecret: GITHUB_CLIENT_SECRET,
        callbackURL: "http://127.0.0.1:3000/auth/github/callback"
      },
      function(token, refreshToken, profile, done) {
        User.findOne({ githubId: profile.id }, function (err, user) {
        if (err) {
            return done(err);
        }
        // if the user is found, then log them in
        if (user) {
            return done(null, user); // user found, return that user
        } else {
            // if there is no user found with that facebook id, create them
            var newUser            = new User();
github freecodecamp-spb / web_dev_courses_Front_End / settings / passport.js View on Github external
module.exports = function(passport) {

  passport.serializeUser(function(user, done) {
    done(null, user.id);
  });

  passport.deserializeUser(function(id, done) {
    User.findById(id, function(err, user) {
      done(err, user);
    });
  });

  // Модуль Стратегии авторизации.
  passport.use('github', new GitHubStrategy({
      clientID: configAuth.githubAuth.clientID,
      clientSecret: configAuth.githubAuth.clientSecret,
      callbackURL: configAuth.githubAuth.callbackURL
    },
    function(accessToken, refreshToken, profile, done) {
      process.nextTick(function() {
        authCallback('github', profile, {accessToken, refreshToken}, done);
      });
    }
  ));
};
github remy / jsonbin / lib / strategy / github.js View on Github external
const undefsafe = require('undefsafe');
const passport = require('passport');
const request = require('request');
const User = require('../db/user');
const Strategy = require('passport-github2').Strategy;

const strategy = new Strategy({
  clientID: process.env.GITHUB_CLIENT_ID,
  clientSecret: process.env.GITHUB_SECRET,
  callbackURL: process.env.GITHUB_CALLBACK,
}, (accessToken, refreshToken, profile, done) => {
  const email = undefsafe(profile, 'emails.0.value');
  User
    .findOrCreate({ githubId: profile.id, email }, profile._json)
    .then(user => {
      if (user.email) {
        return done(null, user);
      }

      // otherwise go get their email address and store it
      request({
        url: 'https://api.github.com/user/emails',
        json: true,
github remy / next-training / routes / strategy / github.js View on Github external
const passport = require('passport');
const request = require('request');
const User = require('../db/user');
const Strategy = require('passport-github2').Strategy;

const strategy = new Strategy(
  {
    clientID: process.env.GITHUB_CLIENT_ID,
    clientSecret: process.env.GITHUB_SECRET,
    // callbackURL: process.env.GITHUB_CALLBACK,
  },
  (accessToken, refreshToken, profile, done) => {
    User.findOrCreate({ githubId: profile.id }, profile._json)
      .then(user => {
        if (user.email) {
          return done(null, user);
        }

        // otherwise go get their email address and store it
        request(
          {
            url: 'https://api.github.com/user/emails',
github eclipse / orion.client / modules / orionode / lib / user.js View on Github external
function configureGithubOAuth(app, options) {
	if (options.configParams.get("orion.oauth.github.client")) {
		const GithubStrategy = require('passport-github2').Strategy;
		passport.use(new GithubStrategy({
			clientID: options.configParams.get("orion.oauth.github.client"),
			clientSecret: options.configParams.get("orion.oauth.github.secret"),
			passReqToCallback: true,
			callbackURL: (options.configParams.get("orion.auth.host") || "") + "/auth/github/callback",
			scope: "user:email"
		}, /* @callback */ function(req, accessToken, refreshToken, profile, done) {
			const email = profile.emails[0].value;
			oauth(profile.provider + "/" + profile.id, profile.username, email, req, done);
		}));
		app.get('/login/oauth/github', options.basicMiddleware, passport.authenticate('github'));
		app.get('/mixlogin/manageoauth/oauth/github', options.basicMiddleware, passport.authenticate('github', {callbackURL: (options.configParams.get("orion.auth.host") || "") + "/auth/github/callback/link"}));
		app.get('/auth/github/callback*', options.basicMiddleware, function(req, res) {
			return passport.authenticate('github', {callbackURL: (options.configParams.get("orion.auth.host") || "") + "/auth/github/callback" + (req.params["0"] || "")}, /* @callback */ function(err, user, info){
				createNewUser(req,res,err,user, options);
			})(req,res);
		});

passport-github2

GitHub authentication strategy for Passport.

MIT
Latest version published 5 years ago

Package Health Score

53 / 100
Full package analysis

Popular passport-github2 functions