node package manager
Loosely couple your services. Use Orgs to version and reuse your code. Create a free org »



Passport strategies for authenticating with MediaWiki using OAuth 1.0a. Documentation and code shamelessly adapted from Jared Hanson's Passport-Google-OAuth.

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


$ npm install passport-mediawiki-oauth

Usage of OAuth 1.0

Configure Strategy

The MediaWiki OAuth 1.0 authentication strategy authenticates users using a MediaWiki account and OAuth tokens. The strategy requires a verify callback, which accepts these credentials and calls done providing a user, as well as options specifying a consumer key, consumer secret, and callback URL.

var MediaWikiStrategy = require('passport-mediawiki-oauth').OAuthStrategy;
passport.use(new MediaWikiStrategy({
  function(token, tokenSecret, profile, done) {
    User.findOrCreate({ mediawikiGlobalId: }, function (err, user) {
      return done(err, user);

Authenticate Requests

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

For example, as route middleware in an Express application:

  passport.authenticate('mediawiki', { scope: MEDIAWIKI_AUTH_SCOPE }));
  passport.authenticate('mediawiki', { failureRedirect: '/login' }),
  function(req, res) {
    // Successful authentication, redirect home.


For a complete, working example, refer to the OAuth 1.0 example. To get it up and running, you can do:

$ cd examples/oauth
$ npm install
$ node app.js


$ npm install --dev
$ make test

Build Status



The MIT License