oauth2-server

oauth2-server is a complete, compliant and well tested module for implementing an OAuth2 server in Node.js. The project is hosted on GitHub and the included test suite is automatically run on Travis CI.

Installation

Example Usage

const OAuth2Server = require('oauth2-server');
const Request = OAuth2Server.Request;
const Response = OAuth2Server.Response;

const oauth = new OAuth2Server({
  model: require('./model')
});

let request = new Request({
  method: 'GET',
  query: {},
  headers: {Authorization: 'Bearer foobar'}
});

let response = new Response({
  headers: {}
});

oauth.authenticate(request, response)
  .then((token) => {
    // The request was successfully authenticated.
  })
  .catch((err) => {
    // The request failed authentication.
  });

See the Model Specification of what is required from the model passed to OAuth2Server.