passport-vso
v0.0.3
Published
Visual Studio Online authentication strategy for Passport.
Downloads
18
Maintainers
Readme
passport-vso
Passport strategy for authenticating with Visual Studio Online accounts using the OAuth 2.0 API.
This module lets you authenticate using Visual Studio Online in your Node.js applications. Visual Studio Online authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
Install
$ npm install passport-vso
Usage
Configure Strategy
The Visual Studio Online authentication strategy authenticates users using a VSO
account and OAuth 2.0 JWT bearer tokens. The strategy requires a verify
callback,
which accepts these credentials and calls done
providing a user, as well as
options
specifying a client ID, client secret, and callback URL.
passport.use(new VsoOAuth2Strategy({
clientID: VSO_CLIENT_ID,
clientSecret: VSO_CLIENT_SECRET,
callbackURL: "http://www.example.com/auth/vso/callback"
},
function(accessToken, refreshToken, profile, done) {
User.findOrCreate({ vsoId: profile.id }, function (err, user) {
return done(err, user);
});
}
));
Authenticate Requests
Use passport.authenticate()
, specifying the 'vso'
strategy, to
authenticate requests.
For example, as route middleware in an Express application:
app.get('/auth/vso',
passport.authenticate('vso', { scope: ['wl.signin', 'wl.basic'] }));
app.get('/auth/vso/callback',
passport.authenticate('vso', { failureRedirect: '/login' }),
function(req, res) {
// Successful authentication, redirect home.
res.redirect('/');
});
Examples
For a complete, working example, refer to the login example.
Tests
$ npm install
$ npm test
Credits
- Patrick Hallisey
- Mickey Mullin
Forked from passport-windowslive by Jared Hanson
License
Copyright (c) 2015 Patrick Hallisey