Skip to content

brainflake/passport-hubspot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Passport-Hubspot

This repo is being depcrecated in favor of passport-hubspot-oauth2 which is being actively maintained and is current with HubSpot's OAuth 2.0 implementation.

Passport strategy for authenticating with HubSpot using the OAuth 2.0 API.

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

Usage

Configure Strategy

The HubSpot authentication strategy authenticates users using a HubSpot account and OAuth 2.0 tokens.

NOTE: Unlike normal OAuth 2.0 flows, HubSpot immediately returns an access token instead of an authorization code. Therefore, unlike other passport strategies, this strategy does not actually call the verify callback.

passport.use(new HubSpotStrategy({
    clientID: HUBSPOT_APP_ID,
    clientSecret: HUBSPOT_APP_SECRET,
    callbackURL: "http://localhost:3000/auth/hubspot/callback"
  }, function() {
    // Useless verify callback.
  };
));

Authenticate Requests

Use passport.authenticate(), specifying the 'hubspot' strategy, to authenticate requests. You'll also need to provide a portalId and any scopes you'll need access to.

For example, as route middleware in an Express application:

app.get('/auth/hubspot', passport.authenticate('hubspot', {
    portalId: 62515,
    scope: ['offline', 'contacts-ro', 'contacts-rw']
  })
);

app.get('/auth/hubspot/callback', function(req, res) {
    // Access tokens are returned immediately as params, which you can then store somehow.
    console.log(req.params);

    // Redirect to home.
    res.redirect('/');
});

Credits

Based on the great work of Brian Falk (@brainflake) and Jonathan K (@hijonathan)

Code based on passport-facebook by Jared Hanson

License

The MIT License

About

A Passport strategy for HubSpot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published