Using connect middleware in Webapp.connectedHandlers

I’m trying to integrate passport.js which uses the node connect middleware. The connect library is what Webapp exposes in Webapp.connectedHandlers ( ). Most passport examples use express, none with meteor.

The closest thing I could find is:

From reading passport, using a unique token strategy should be simple.

const passport = require('passport')
const UniqueTokenStrategy = require('passport-unique-token').Strategy
const debug = require('debug')('wireline:passport')


passport.use(new UniqueTokenStrategy(
    function (token, done) {
      console.log('token', token) // no logs appearing
      if ( token ){
        return done(null, 'ok');

      } else {
        done('err', null)

// passport.authenticate generates the callback function 'connect' would need
callbackFunc =  passport.authenticate('token')

WebApp.connectHandlers.use('/passportTestRoute', callbackFunc)

It doesn’t throw any exception. On requesting the route, it doesn’t seem to run the function, since the consoe.log check isn’t printed. All I get is a bad request as the response in the browser, and no meaningful logs.

Any thoughts?

Hi @lpgeiger

I checked your example and it does work fine. Are you passing token parameter in url?


It did show me Bad request when I wan’t passing token.