{"id":16874,"library":"passport-hubspot-postilize","title":"Passport-Hubspot-postilize Authentication Strategy","description":"This package provides a Passport.js strategy for authenticating users against HubSpot using the OAuth 2.0 protocol. It enables Node.js applications, particularly those built with Connect-style middleware like Express, to integrate HubSpot login functionality. The current stable version is 1.0.1. The \"postilize\" suffix in the name suggests it might be a specialized or modified fork of a more general `passport-hubspot` library, potentially indicating a focused scope or a specific set of customizations. This strategy allows developers to configure authentication using HubSpot client ID, client secret, and a callback URL. It integrates with Passport's `passport.authenticate()` middleware to manage the OAuth flow, returning user profile data that includes `hub_id`, `hub_domain`, and `user_id`. While the exact release cadence isn't specified, its specialized nature might mean updates are less frequent than a foundational library.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","passport","hubspot","auth","authentication","identity"],"install":[{"cmd":"npm install passport-hubspot-postilize","lang":"bash","label":"npm"},{"cmd":"yarn add passport-hubspot-postilize","lang":"bash","label":"yarn"},{"cmd":"pnpm add passport-hubspot-postilize","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package is a Passport.js strategy and requires Passport to function.","package":"passport","optional":false},{"reason":"Commonly used Connect-style middleware framework for integrating Passport strategies.","package":"express","optional":true}],"imports":[{"note":"The strategy class is typically a named export, though the `require` example directly assigns the main export which itself *is* the Strategy constructor.","wrong":"import HubSpotStrategy from 'passport-hubspot-postilize'","symbol":"HubSpotStrategy","correct":"import { Strategy as HubSpotStrategy } from 'passport-hubspot-postilize';\n// Or for CommonJS:\nconst HubSpotStrategy = require('passport-hubspot-postilize').Strategy;"},{"note":"Passport itself must be imported separately, as this package only provides the strategy, not the core Passport library.","wrong":"const passport = require('passport-hubspot-postilize');","symbol":"passport","correct":"import passport from 'passport';"}],"quickstart":{"code":"import express from 'express';\nimport passport from 'passport';\nimport { Strategy as HubSpotStrategy } from 'passport-hubspot-postilize';\n\nconst app = express();\n\n// Dummy values for example, replace with actual environment variables\nconst HUBSPOT_CLIENT_ID = process.env.HUBSPOT_CLIENT_ID ?? 'YOUR_HUBSPOT_CLIENT_ID';\nconst HUBSPOT_CLIENT_SECRET = process.env.HUBSPOT_CLIENT_SECRET ?? 'YOUR_HUBSPOT_CLIENT_SECRET';\nconst CALLBACK_URL = process.env.HUBSPOT_CALLBACK_URL ?? 'http://localhost:3000/auth/hubspot/callback';\n\napp.use(passport.initialize());\n\npassport.use(new HubSpotStrategy({\n    clientID:     HUBSPOT_CLIENT_ID,\n    clientSecret: HUBSPOT_CLIENT_SECRET,\n    callbackURL:  CALLBACK_URL,\n    passReqToCallback: true\n  },\n  function(request, accessToken, refreshToken, profile, done) {\n    // In a real application, you would find or create a user in your database\n    // based on the profile information. For this example, we just return the profile.\n    // console.log('HubSpot Profile:', profile);\n    return done(null, profile);\n  }\n));\n\n// Configure Passport to serialize and deserialize users (required for session support)\npassport.serializeUser((user, done) => done(null, user));\npassport.deserializeUser((obj, done) => done(null, obj));\n\napp.get('/auth/hubspot',\n  passport.authenticate('hubspot', { scope: 'contacts content' })\n);\n\napp.get( '/auth/hubspot/callback',\n  passport.authenticate( 'hubspot', {\n    successRedirect: '/auth/hubspot/success',\n    failureRedirect: '/auth/hubspot/failure'\n}));\n\napp.get('/auth/hubspot/success', (req, res) => {\n  res.send('HubSpot authentication successful!');\n});\n\napp.get('/auth/hubspot/failure', (req, res) => {\n  res.send('HubSpot authentication failed!');\n});\n\napp.listen(3000, () => {\n  console.log('Server running on http://localhost:3000');\n  console.log('Initiate auth by visiting http://localhost:3000/auth/hubspot');\n});","lang":"typescript","description":"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."},"warnings":[{"fix":"Ensure that `passport.authenticate()` explicitly specifies `'hubspot'` for HubSpot authentication, e.g., `passport.authenticate('hubspot', ...)`.","message":"The example code provided in the original `README` for `/auth/hubspot` route middleware incorrectly uses `'google'` instead of `'hubspot'` as the strategy name. This is a common copy-paste error that can lead to an 'Unknown authentication strategy' error.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Review the package's GitHub repository or npm page for details on its specific modifications or purpose. Compare its features and maintenance status with other available HubSpot Passport strategies if specific customizations are not needed.","message":"The package name `passport-hubspot-postilize` suggests it might be a specialized fork or modified version of a more generic `passport-hubspot` package. Users should verify if this specific variant meets their requirements or if a different, potentially more actively maintained `passport-hubspot` library is more suitable.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Change `passport.authenticate('google', ...)` to `passport.authenticate('hubspot', ...)` in your route definitions.","cause":"The authentication strategy name passed to `passport.authenticate()` is `'google'` when it should be `'hubspot'` for this package.","error":"Error: Unknown authentication strategy \"google\""},{"fix":"Verify 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.","cause":"The `callbackURL` configured in the HubSpot API application settings does not exactly match the `callbackURL` provided in the `HubSpotStrategy` options.","error":"OAuthCallbackError: Redirect URL mismatch"}],"ecosystem":"npm","meta_description":null}