Socket
Book a DemoInstallSign in
Socket

passport-mailchimp

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

passport-mailchimp

Mailchimp authentication strategy for Passport.

latest
npmnpm
Version
1.1.0
Version published
Weekly downloads
990
72.47%
Maintainers
2
Weekly downloads
 
Created
Source

Passport-MailChimp

Passport strategy for authenticating with MailChimp using the OAuth 2.0 API.

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

Usage

Configure Strategy

The MailChimp authentication strategy authenticates users using a MailChimp 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 MailChimpStrategy({
    clientID: MAILCHIMP_APP_ID,
    clientSecret: MAILCHIMP_APP_SECRET,
    callbackURL: "http://localhost:3000/auth/mailchimp/callback"
  }, function (accessToken, refreshToken, profile, done) {
    User.findOrCreate({ mailchimpId: mailchimp.id }, function(err, user) {
      return done(err, user);
    });
  }
));

Authenticate Requests

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

For example, as route middleware in an Express application:

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

app.get('/auth/mailchimp/callback',
  passport.authenticate('mailchimp', { 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

Keywords

mailchimp

FAQs

Package last updated on 23 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts