passport-surveymonkey

1.1.1 • Public • Published

passport-surveymonkey

SurveyMonkey authentication strategy for Passport.

This module lets you authenticate using SurveyMonkey OAuth in your Node.js applications. Connect-style middleware, including Express.

Usage

Configure Strategy

The SurveyMonkey authentication strategy authenticates users using a third-party account and SurveyMonkey tokens. The provider's OAuth 2.0 endpoints, as well as the client identifer and secret, are specified as options. The strategy requires a verify callback, which receives an access token and profile, and calls done providing a user.

var SurveyMonkeyStrategy = require('passport-surveymonkey').Strategy;

passport.use(new SurveyMonkeyStrategy({      
    clientID: 'SURVEYMONKEY USERNAME',
    clientSecret: SURVEYMONKEY APP SECRET,
    api_key: SURVEYMONKEY APP_KEY,
    callbackURL: "http://yoursite.com/auth/example/callback"
  },
  function(accessToken, refreshToken, profile, done) {
    User.findOrCreate({ exampleId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

Authenticate Requests

Use passport.authenticate(), specifying the 'surveymonkey' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.get('/auth/example',
  passport.authenticate('surveymonkey'));

app.get('/auth/example/callback',
  passport.authenticate('surveymonkey', { failureRedirect: '/login' }),
  function(req, res) {
    // Successful authentication, redirect home.
    res.redirect('/');
  });

Credits

License

The MIT License

Package Sidebar

Install

npm i passport-surveymonkey

Weekly Downloads

6

Version

1.1.1

License

none

Last publish

Collaborators

  • royvandewater