node.js - Manually call passport for authentication -
i develop restful nodejs api protected oauth2 authentication using passport. var express = require('express'); var passport = require('passport'); var port = process.env.port || 8080; var app = express(); app.use(passport.initialize()); // create our express router var router = express.router(); var creaturecontroller = require('./controllers/creature'); router.route('/creature').get(passport.authenticate('accesstoken', {session: false}), creaturecontroller.getprofile); in case, route protected , requires send valid token in order access route. i want find way authenticate "users" manually, calling function, take username , password of user want authenticate. passport exposes req.login() function can used login user manually. app.post('/login', function (req, res, next) { var user = user.findorcreate(req.body); // … authentication or whatever req.login(user, ...