passport-constantcontact

0.0.1 • Public • Published

Passport-ConstantContact

Passport strategy for authenticating with Constant Contact using the OAuth 2.0 API.

This module lets you authenticate using Constant Contact in your Node.js applications. By plugging into Passport, Constant Contact authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.

Usage

Configure Strategy

The Constant Contact authentication strategy authenticates users using a Constant Contact account and OAuth 2.0 tokens. The strategy requires a verify callback, which accepts these credentials and calls done providing a user, as well as options specifying a app ID, app secret, and callback URL.

passport.use(new ConstantContactStrategy({
    clientID: CONSTANT_CONTACT_CLIENT_ID,
    clientSecret: CONSTANT_CONTACT_CLIENT_SECRET,
    callbackURL: "http://localhost:3000/auth/constantcontact/callback"
  }, function (accessToken, refreshToken, profile, done) {
    User.findOrCreate({ constantContactUsername: profile.user_name }, function(err, user) {
      return done(err, user);
    });
  }
));

Authenticate Requests

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

For example, as route middleware in an Express application:

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

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

Credits

Created by Brian Falk

Code based on passport-facebook by Jared Hanson

License

The MIT License

Readme

Keywords

none

Package Sidebar

Install

npm i passport-constantcontact

Weekly Downloads

6

Version

0.0.1

License

BSD

Last publish

Collaborators

  • brainflake