{"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.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install passport-hubspot-postilize"],"cli":null},"imports":["import { Strategy as HubSpotStrategy } from 'passport-hubspot-postilize';\n// Or for CommonJS:\nconst HubSpotStrategy = require('passport-hubspot-postilize').Strategy;","import passport from 'passport';"],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}