Have ideas to improve npm?Join in the discussion! »

passport-xeroTypeScript icon, indicating that this package has built-in type declarations

1.0.0-a • Public • Published

passport-xero

Passport strategy for authenticating with Smart Sheets using the OAuth 1.0a API.

This module lets you authenticate using Smart Sheets in your Node.js applications. By plugging into Passport, Smart Sheets authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.

Install

$ npm install passport-xero

Usage

Configure Strategy

passport.use(new XeroStrategy({
    consumerKey : XERO_CLIENT_KEY,
    consumerSecret: XERO_CLIENT_SECRET,
    callbackURL: "http://127.0.0.1:3000/auth/xero/callback"
  },
  function(token, tokenSecret, profile, done) {
    User.findOrCreate({ xeroId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

Authenticate Requests

Use passport.authenticate(), specifying the 'xero' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.get('/auth/xero',
  passport.authenticate('xero'));

app.get('/auth/xero/callback',
  passport.authenticate('xero', { failureRedirect: '/login' }),
  function(req, res) {
    // Successful authentication, redirect home.
    res.redirect('/');
  });

License

The MIT License

Install

npm i passport-xero

DownloadsWeekly Downloads

345

Version

1.0.0-a

License

none

Last publish

Collaborators

  • avatar