Socket
Socket
Sign inDemoInstall

passport-wordpress

Package Overview
Dependencies
9
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    passport-wordpress

Wordpress OAuth2 strategy for Passport.


Version published
Maintainers
1
Install size
261 kB
Created

Readme

Source

Passport-Wordpress

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

Install

$ npm install passport-wordpress

Usage

Configure Strategy

The Wordpress authentication strategy authenticates users using a Wordpress 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 client ID, client secret, and callback URL.

passport.use(new WordpressStrategy({
    clientID: CLIENT_ID,
    clientSecret: CLIENT_SECRET
  },
  function(accessToken, refreshToken, profile, done) {
    User.findOrCreate({ WordpressId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));
Authenticate Requests

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

For example, as route middleware in an Express application:

app.get('/auth/wordpress',
  passport.authorize('wordpress'));

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

Thanks

License

The MIT License

Copyright (c) 2013 Michael Pearson <http://github.com/mjpearson>

Keywords

FAQs

Last updated on 23 May 2016

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc