Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including passport-smartsheet with all npm packages installed. Try it out:

var passportSmartsheet = require("passport-smartsheet")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

passport-smartsheet v1.0.2

Smartsheet authentication strategy for Passport.

passport-smartsheet

Passport strategy for authenticating with Smartsheet using the OAuth 2.0a API.

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

Install

$ npm install passport-smartsheet

Usage

Configure Strategy

passport.use(new SmartsheetStrategy({
    clientID : SMARTSHEET_CLIENT_KEY,
    clientSecret: SMARTSHEET_CLIENT_SECRET,
    callbackURL: "http://127.0.0.1:3000/auth/smartsheet/callback",
    scope: ["READ_USERS"],
    tokenURL: "https://api.smartsheet.com/2.0/token" //this tokenURL defaults to the deprecated 1.1 api, 
  },
  function(token, tokenSecret, profile, done) {
    User.findOrCreate({ smartsheetId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

Authenticate Requests

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

For example, as route middleware in an Express application:

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

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

License

The MIT License

Copyright (c) 2011-2013 Jared Hanson <http://jaredhanson.net/>

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free