 <p>Note that: basicAuth is deprecated</p> <p>Here the code:</p> <pre><code>app.use(express.basicAuth(function(user, pass, callback){ if(config.credentials.clients[user] === undefined) { callback('user not found!!!'); } else { if(config.credentials.clients[user].password === pass) { callback(null, config.credentials.clients[user]); } else { callback('wrong pass!!!'); } } }); app.post('/put', function putEvents(req, res) { console.log(req.user.name) res.end(); }); </code></pre>