npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

edx-oauth-middleware

v0.0.8

Published

Provides Express middleware for Open edX oauth

Downloads

6

Readme

edx-oauth-middleware

Provides Express.js middleware for Open edX oauth, based on simple-oauth2. Package exposes commonly used middleware for basic oauth with Open edX:

  • authorize - redirects user to Open edX LMS. After signing in, user is redirected back to the provided external app's loginUrl

  • storeAccessToken - stores access token to session, then calls next middleware

  • logout - destroys session and redirects to Open edX logout page, unless specified otherwise with req.params.query.no_redirect set to True.

Install

npm install --save edx-oauth-middleware

Example

Importing and initializing module

This is default config, which is also set with calling init method with empty object:

require('edx-oauth-middleware').init({});

It is up to developer to provide custom config if required

const config = {
  loginUrl: 'http://localhost:3000/users/login',
  redirectOnLoginUrl: 'http://localhost:3000',
  lmsUrl: 'http://localhost:8000',
  edxLogoutUrl: 'http://localhost:8000/logout',
  client: {
    id: 'id',
    secret: 'secret'
  },
  auth: {
    tokenHost: 'http://localhost:8000',
    authorizePath: "/oauth2/authorize",
    tokenPath: "/oauth2/access_token/"
  }
};

const { authorize, storeAccessToken, logout } = require('edx-oauth-middleware').init(config);

Usage in custom application

const axios = require('axios');

router.get('/auth', authorize);
router.get('/login', storeAccessToken, (req, res) => {
  const accessToken = req.session.token.access_token;
  const options = {
    method: 'GET',
    url: 'localhost:8000/oauth2/user_info',
    headers: {
      Authorization: `Bearer ${accessToken}`
    }
  };

  axios(options)
  .then(response => {
    req.session.user = response.data;
    res.redirect('/');
  })
  .catch(error => res.send(`Access Token Error ${error.message}`));
});
router.get('/logout', logout);