oauthjs / express-oauth-server

Complete, compliant and well tested module for implementing an OAuth2 Server/Provider with express in node.js
MIT License
484 stars 384 forks source link

Mixing `oauth2-server` versions breaks `instanceof` Require #78

Open wallzero opened 6 years ago

wallzero commented 6 years ago

If using this project with latest oauth2-server, express-oauth-server will fail if using custom express middleware. For example:

      const req = new Request(request);
      const res = new Response(response);

      expressOAuthServer.server.token(req, res).then(() => {
          /* stuff */
      })

The above will throw this error.

This occurs if the parent project is using a newer version of oauth2-server than the one listed in express-oauth-server package.json. The instanceof fails I suppose due to newer class properties; though I haven't looked into it.

A workaround is to import Require and Response from node_modules/express-oauth-server/node_modules/oauth2-server. This will be fixed once the project is updated to use the latest oauth2-server.