How to use passport-facebook-token - 9 common examples

To help you get started, we’ve selected a few passport-facebook-token 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 garage-it / SmartHouse-backend / src / API / auth / facebook / passport.js View on Github external
export default function setup(UserService, facebookConfig) {
    passport.use(new FacebookTokenStrategy({
        clientID: facebookConfig.clientID,
        clientSecret: facebookConfig.clientSecret
    }, (accessToken, refreshToken, profile, done) => {
        const mainPublicEmail = profile.emails[0].value;

        if (!mainPublicEmail) {
            // Some times it happens
            // https://developers.facebook.com/bugs/298946933534016/?comment_id=620710881344692
            // https://developers.facebook.com/docs/graph-api/reference/user
            done(new Error('Facebook Auth: Not found e-mail in profile'));
            return;
        }

        UserService.findOrCreateUser(
            {
                email: mainPublicEmail
github minhuyen / generator-expressjs-rest / generators / app / templates / backend / src / services / passport.js View on Github external
.exec(function(err, user) {
        if (err) {
          return done(err, false);
        }
        if (user) {
          done(null, user);
        } else {
          done(null, false);
        }
      });
  })
);

// Facebook
passport.use(
  new FacebookTokenStrategy(
    {
      clientID: config.facebook.clientID,
      clientSecret: config.facebook.clientSecret,
      profileFields: ['id', 'first_name', 'last_name', 'email', 'picture']
    },
    function(accessToken, refreshToken, profile, done) {
      // asynchronous
      process.nextTick(function() {
        profile = profile['_json'];
        logger.info('========profile=--=======', profile);
        // find the user in the database based on their facebook id
        User.findOne({ email: profile.email }, function(err, user) {
          // if there is an error, stop everything and return that
          // ie an error connecting to the database
          if (err) return done(err);
github xiexiangyi0 / PicsHouse-Android / server / util / auth.js View on Github external
require("../model/user").findOne({token : token}, function(err, user) {
            if(err) {
                return done(err);
            }

            if(user) {
                return done(null, user);
            } else {
                return done(null, false, {message : "invalid_token"});
            }
        });
    })
);

passport.use(
    new FBTokenStrategy({
        clientID : app_config.FB_CLIENT_ID
        , clientSecret : app_config.FB_CLIENT_SECRET
    }
    , function(accessToken, refreshToken, profile, done) {
            var User = require("../model/user");
            //console.log(profile);
            User.findOne({"facebook.id" : profile.id}, function(err, user) {

                if(err) {
                    return done(err);
                }

                if(user) {
                    user.token = accessToken;
                } else {
github connect-foundation / 2019-13 / back / src / passport / index.js View on Github external
update: {
              email,
              name,
              picture,
            },
          });

          done(null, user);
        } catch (e) {
          done(e);
        }
      },
    ),
  );
  passport.use(
    new FacebookTokenStrategy(
      {
        clientID: process.env.FACEBOOK_APP_ID,
        clientSecret: process.env.FACEBOOK_APP_SECRET,
      },
      async (accessToken, refreshToken, profile, done) => {
        const {
          id, displayName, emails, photos,
        } = profile;
        try {
          const user = await prisma.upsertUser({
            where: {
              id: `F-${id}`,
            },
            create: {
              id: `F-${id}`,
              email: emails[0].value,
github lorenzopicoli / node-api-starter / config / passport.js View on Github external
const match = await user.validatePassword(password)

      if (!match) {
        return done(false)
      }

      done(user)
    } catch (err) {
      done(err)
    }
  } catch (err) {
    return done(err)
  }
}))

passport.use('facebook-token', new FacebookTokenStrategy(config.facebook, async (accessToken, refreshToken, profile, done) => {
  if (!accessToken || !profile.id) {
    return done('something', null)
  }
  return done(null, {'profile': profile, 'facebook_token': accessToken})
}))
github soha-moosa / node-auth-kit / controllers / passport.js View on Github external
return done(null, user);
      } catch (err) {
        done(err);
      }
    }
  )
);

/**
 * @FacebookTokenStrategy : The Facebook authentication strategy authenticates users using a Facebook
 *                     account and OAuth 2.0 tokens.
 */

passport.use(
  'facebookToken',
  new FacebookTokenStrategy(
    {
      clientID: process.env.FACEBOOK_APP_ID,
      clientSecret: process.env.FACEBOOK_APP_SECRET
    },
    async (accessToken, refreshToken, profile, cb) => {
      try {
        const user = await User.findOne({ 'facebook.id': profile.id });
        if (user) {
          return cb(null, user);
        }
        const {
          id,
          displayName,
          name: { givenName, familyName },
          emails
        } = profile;
github Talento90 / node-project-struct / config / passport.js View on Github external
firstName: profile._json.first_name,
            lastName: profile._json.last_name,
            email: profile._json.email
          };

          User.create(user, function(err, user){
            if(err){ return done(err, null); }
            return done(err, user);
          });
        }

      });
    });
  }));

  passport.use(new FacebookTokenStrategy({
    clientID: config.passport.facebook.clientID,
    clientSecret: config.passport.facebook.clientSecret
  },
  function(accessToken, refreshToken, profile, done) {
    User.findOrCreate({ facebookId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }));

}
github ghaiklor / generator-sails-rest-api / generators / app / templates / config / passport.js View on Github external
code: 'E_AUTH_FAILED',
          message: [profile.provider, ' auth failed'].join('')
        });

        return next(null, user, {});
      })
      .catch(next);
  } else {
    req.user.socialProfiles[profile.provider] = profile._json;
    req.user.save(next);
  }
}

passport.use(new LocalStrategy(_.assign({}, LOCAL_STRATEGY_CONFIG), _onLocalStrategyAuth));
passport.use(new JwtStrategy(_.assign({}, JWT_STRATEGY_CONFIG), _onJwtStrategyAuth));
passport.use(new FacebookTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new TwitterTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new VKontakteTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new FoursquareTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new GitHubTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new InstagramTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new PayPalTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new RedditTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new SoundCloudTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new WindowsLiveTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new TwitchTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new YandexTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new AmazonTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new GooglePlusTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
passport.use(new YahooTokenStrategy(_.assign({}, SOCIAL_STRATEGY_CONFIG), _onSocialStrategyAuth));
github BernardTolosajr / ember-cli-koa-facebookauth-example / auth-server / config / passport.js View on Github external
module.exports = function(passport) {
  passport.serializeUser(serialize);
  passport.deserializeUser(deserialize);
  passport.use(new FacebookTokenStrategy({
    clientID: 'facebook_id',
    clientSecret: 'facebook_secrect_key',
    redirectURL: 'facebook_redirect_url'
  }, facebookAuth));
};

passport-facebook-token

Facebook token authentication strategy for Passport

MIT
Latest version published 5 years ago

Package Health Score

54 / 100
Full package analysis

Popular passport-facebook-token functions