Freshbooks authentication strategy for Passport.

npm install passport-freshbooks
8 downloads in the last month


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

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

This module is a straight copy/paste from Jared Hanson's excellent Passport LinkedIn module.

LinkedIn and Freshbooks both use oAuth1.0a so it seemed like a good place to start.


$ npm install passport-freshbooks


Configure Strategy

For a working example, see ./examples/login/app.js.

The Freshbooks authentication strategy authenticates users using a Freshbooks account and OAuth tokens. The strategy requires a verify callback, which accepts these credentials and calls done providing a user, as well as options specifying a consumer key, consumer secret, and callback URL.

passport.use(new FreshbooksStrategy({

    // This is your Freshbooks subdomain.  e.g. `example` in ``
    consumerKey: SUBDOMAIN,

    // This is your OAuth Secret from My Account -> Freshbooks API.
    consumerSecret: FRESHBOOKS_OAUTH_SECRET,

    // This callback needs to be the same servername as the app.  localhost !=
    callbackURL: ""
  function(token, tokenSecret, profile, done) {
    User.findOrCreate({ freshbooksId: }, function (err, user) {
      return done(err, user);

Authenticate Requests

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

For example, as route middleware in an Express application:


  passport.authenticate('freshbooks', { failureRedirect: '/login' }),
  function(req, res) {
    // Successful authentication, redirect home.

Profile Fields

The Freshbooks profile contains a lot of information.

See ./examples/login/views/account.ejs and ./examples/login/app.js for more info


For a complete, working example, refer to the login example.



The MIT License

Copyright (c) 2013 Michael Cole [](

npm loves you