Registry /
auth-security / passport-hubspot-postilize
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
HubSpotStrategy
✓ import { Strategy as HubSpotStrategy } from 'passport-hubspot-postilize';
// Or for CommonJS:
const HubSpotStrategy = require('passport-hubspot-postilize').Strategy;
✗ import HubSpotStrategy from 'passport-hubspot-postilize'
The strategy class is typically a named export, though the `require` example directly assigns the main export which itself *is* the Strategy constructor.
passport
✓ import passport from 'passport';
✗ const passport = require('passport-hubspot-postilize');
Passport itself must be imported separately, as this package only provides the strategy, not the core Passport library.
This quickstart demonstrates how to set up HubSpot OAuth 2.0 authentication in an Express application using Passport.js, configuring the strategy and defining routes for initiating the login and handling the callback.
import express from 'express';
import passport from 'passport';
import { Strategy as HubSpotStrategy } from 'passport-hubspot-postilize';
const app = express();
// Dummy values for example, replace with actual environment variables
const HUBSPOT_CLIENT_ID = process.env.HUBSPOT_CLIENT_ID ?? 'YOUR_HUBSPOT_CLIENT_ID';
const HUBSPOT_CLIENT_SECRET = process.env.HUBSPOT_CLIENT_SECRET ?? 'YOUR_HUBSPOT_CLIENT_SECRET';
const CALLBACK_URL = process.env.HUBSPOT_CALLBACK_URL ?? 'http://localhost:3000/auth/hubspot/callback';
app.use(passport.initialize());
passport.use(new HubSpotStrategy({
clientID: HUBSPOT_CLIENT_ID,
clientSecret: HUBSPOT_CLIENT_SECRET,
callbackURL: CALLBACK_URL,
passReqToCallback: true
},
function(request, accessToken, refreshToken, profile, done) {
// In a real application, you would find or create a user in your database
// based on the profile information. For this example, we just return the profile.
// console.log('HubSpot Profile:', profile);
return done(null, profile);
}
));
// Configure Passport to serialize and deserialize users (required for session support)
passport.serializeUser((user, done) => done(null, user));
passport.deserializeUser((obj, done) => done(null, obj));
app.get('/auth/hubspot',
passport.authenticate('hubspot', { scope: 'contacts content' })
);
app.get( '/auth/hubspot/callback',
passport.authenticate( 'hubspot', {
successRedirect: '/auth/hubspot/success',
failureRedirect: '/auth/hubspot/failure'
}));
app.get('/auth/hubspot/success', (req, res) => {
res.send('HubSpot authentication successful!');
});
app.get('/auth/hubspot/failure', (req, res) => {
res.send('HubSpot authentication failed!');
});
app.listen(3000, () => {
console.log('Server running on http://localhost:3000');
console.log('Initiate auth by visiting http://localhost:3000/auth/hubspot');
});
Errors
Common errors & fixes
Error: Unknown authentication strategy "google"
The authentication strategy name passed to `passport.authenticate()` is `'google'` when it should be `'hubspot'` for this package.
fixChange `passport.authenticate('google', ...)` to `passport.authenticate('hubspot', ...)` in your route definitions. OAuthCallbackError: Redirect URL mismatch
The `callbackURL` configured in the HubSpot API application settings does not exactly match the `callbackURL` provided in the `HubSpotStrategy` options.
fixVerify that the `callbackURL` property in your `HubSpotStrategy` configuration matches byte-for-byte (including http/https, domain, port, and path) with the 'Redirect URL' or 'Callback URL' configured in your HubSpot developer application settings.
Audit
Dependencies
passportrequiredThis package is a Passport.js strategy and requires Passport to function.
expressoptionalCommonly used Connect-style middleware framework for integrating Passport strategies.