Angular JS + Node JS + Passport + Spring OAuth2 Authentication/Authorization Angular JS + Node JS + Passport + Spring OAuth2 Authentication/Authorization angularjs angularjs

Angular JS + Node JS + Passport + Spring OAuth2 Authentication/Authorization


I do not know if I have to use passport-Bearer or not and how to use-it.

No. There are other options, such as:

Here is an example of how to use passport:

// Express using passport-local// This code is adaptation of examples/express3 from https://github.com/jaredhanson/passport-local// configure Expressapp.configure(function() {// ...app.use(express.session({// The domain should start with a dot, as this allows the subdomain.domain: '.app.local',secret: 'keyboard cat'}));// Enable cors.app.use(function(req, res, next) {res.header('Access-Control-Allow-Credentials', true);res.header('Access-Control-Allow-Origin', req.headers.origin);res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');res.header('Access-Control-Allow-Headers', 'X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept');next();});// ...});app.get('/account', ensureAuthenticated, function(req, res){// Return the current user's infores.json(req.user);});

References