{"id":16873,"library":"passport-sendoso-postilize","title":"Passport Sendoso OAuth 2.0 Strategy","description":"This package provides a Passport authentication strategy specifically designed for integrating with Sendoso using the OAuth 2.0 protocol. It enables Node.js applications, particularly those leveraging Connect-style middleware such as Express, to authenticate users via their Sendoso accounts. The current stable version is 1.0.2, indicating a specific, potentially specialized or modified, integration rather than a general-purpose, high-cadence library. Its key differentiator is its direct focus on Sendoso's unique authentication flow, offering a structured way to connect Passport.js applications to Sendoso for user identity verification. Developers must provide a `clientID`, `clientSecret`, and `callbackURL` to configure the strategy, and a `verify` callback to handle user data after successful authentication. This package simplifies the OAuth 2.0 handshake for Sendoso, allowing Passport's robust session management and user serialization features to be applied.","status":"maintenance","version":"1.0.2","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","passport","sendoso","auth","authentication","identity"],"install":[{"cmd":"npm install passport-sendoso-postilize","lang":"bash","label":"npm"},{"cmd":"yarn add passport-sendoso-postilize","lang":"bash","label":"yarn"},{"cmd":"pnpm add passport-sendoso-postilize","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core authentication framework for which this strategy is built.","package":"passport","optional":false}],"imports":[{"note":"The primary OAuth 2.0 strategy class is typically aliased to 'SendosoStrategy' for clarity in ESM. CommonJS environments use `require('passport-sendoso-postilize').Strategy`.","wrong":"import SendosoStrategy from 'passport-sendoso-postilize';","symbol":"Strategy","correct":"import { Strategy as SendosoStrategy } from 'passport-sendoso-postilize';"},{"note":"The core Passport.js library, usually imported as a default export for direct use with `passport.use()` and `passport.authenticate()`.","wrong":"import * as passport from 'passport';","symbol":"passport","correct":"import passport from 'passport';"}],"quickstart":{"code":"const express = require('express');\nconst passport = require('passport');\nconst session = require('express-session'); // Required for Passport sessions\nconst { Strategy: SendosoStrategy } = require('passport-sendoso-postilize'); // Using destructuring for clarity\n\nconst app = express();\n\n// Passport configuration\npassport.use(new SendosoStrategy({\n    clientID:     process.env.SENDOSO_CLIENT_ID ?? 'YOUR_SENDOSO_CLIENT_ID',\n    clientSecret: process.env.SENDOSO_CLIENT_SECRET ?? 'YOUR_SENDOSO_CLIENT_SECRET',\n    callbackURL:  \"http://localhost:3000/auth/sendoso/callback\",\n    passReqToCallback: true\n  },\n  function(request, accessToken, refreshToken, profile, done) {\n    // In a real application, you would typically find or create a user in your database\n    // based on the profile information returned by Sendoso.\n    // The 'profile' object would contain user details provided by Sendoso.\n    // For demonstration, we'll return a placeholder user.\n    const user = { id: profile?.id || 'sendoso_user_123', name: profile?.displayName || 'Sendoso User' };\n    console.log('Sendoso Profile:', profile);\n    console.log('Access Token:', accessToken);\n    done(null, user); // Call done with null for error and the user object\n  }\n));\n\n// Passport session setup.\n//   To support persistent login sessions, Passport needs to be able to\n//   serialize users into and deserialize users out of the session.\n//   Typically, this will be as simple as storing the user ID when serializing\n//   and finding the user by ID when deserializing.\npassport.serializeUser(function(user, done) {\n  done(null, user.id);\n});\n\npassport.deserializeUser(function(id, done) {\n  // In a real application, retrieve user from database by ID\n  const user = { id: id, name: 'Deserialized User' }; // Placeholder\n  done(null, user);\n});\n\n// Middleware for Express\napp.use(session({ secret: 'keyboard cat', resave: false, saveUninitialized: false }));\napp.use(passport.initialize());\napp.use(passport.session());\n\n// Define authentication routes\napp.get('/auth/sendoso',\n  passport.authenticate('sendoso', { scope: 'profile email' } // Replace 'profile email' with actual Sendoso scopes if available\n));\n\napp.get('/auth/sendoso/callback',\n  passport.authenticate('sendoso', {\n    successRedirect: '/profile', // Redirect to a profile page on success\n    failureRedirect: '/login'    // Redirect to login on failure\n  })\n);\n\napp.get('/profile', (req, res) => {\n  if (req.isAuthenticated()) {\n    res.send(`<h1>Welcome, ${req.user.name || 'authenticated user'}!</h1><pre>${JSON.stringify(req.user, null, 2)}</pre><p><a href=\"/logout\">Logout</a></p>`);\n  } else {\n    res.redirect('/login');\n  }\n});\n\napp.get('/login', (req, res) => {\n  res.send('<h1>Login with Sendoso</h1><p><a href=\"/auth/sendoso\">Login with Sendoso</a></p>');\n});\n\napp.get('/logout', (req, res, next) => {\n  req.logout((err) => {\n    if (err) { return next(err); }\n    res.redirect('/login');\n  });\n});\n\nconst PORT = 3000;\napp.listen(PORT, () => {\n  console.log(`Server running on http://localhost:${PORT}`);\n  console.log('Visit http://localhost:3000/login to start the authentication flow.');\n});","lang":"javascript","description":"Demonstrates how to configure and use the Passport-Sendoso-postilize strategy with Express, including session management, authentication routes, and user serialization/deserialization."},"warnings":[{"fix":"Change `passport.authenticate('google', ...)` to `passport.authenticate('sendoso', ...)` in your routes.","message":"The provided README example for the initial authentication route uses `passport.authenticate('google', ...)` instead of `passport.authenticate('sendoso', ...)`. This is a copy-paste error and should be corrected to `'sendoso'` to use the configured strategy.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Verify that this package is the intended and officially supported Sendoso integration for your project. Consider implications if expecting a standard 'passport-sendoso' library.","message":"The package name `passport-sendoso-postilize` (with unusual capitalization and the 'postilize' suffix) suggests it might be a specific internal or highly customized version, not a generic, community-maintained 'passport-sendoso' package. This could lead to confusion or specific integration quirks.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"For ESM projects, ensure your build system correctly transpiles or handles CommonJS modules. If directly importing, use `import { Strategy as SendosoStrategy } from 'passport-sendoso-postilize';`.","message":"The documentation uses CommonJS `require()` syntax exclusively. While Node.js can often handle mixed modules, explicit ESM (`import`) support or examples are absent, implying it might be primarily tested/designed for CJS environments or require manual configuration for ESM.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Refer to the Sendoso API documentation for the correct OAuth 2.0 scopes required for your application and update `passport.authenticate()` accordingly.","message":"The example authentication scopes `contacts content` are typical for Google OAuth and are unlikely to be valid for Sendoso's OAuth implementation. Actual Sendoso scopes must be used.","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":"Ensure `passport.use(new SendosoStrategy(...))` is called and the strategy name matches what is used in `passport.authenticate('sendoso', ...)`.","cause":"The Passport strategy has not been correctly registered with `passport.use()` before attempting to use it.","error":"Error: Unknown authentication strategy \"sendoso\""},{"fix":"Provide a valid `clientID` string obtained from your Sendoso application registration to the `SendosoStrategy` options.","cause":"The `clientID` option was not provided or was an empty string in the `SendosoStrategy` configuration.","error":"OAuth2Strategy requires a clientID option"},{"fix":"Double-check your `clientSecret` and ensure your `callbackURL` in the strategy configuration precisely matches the one registered in your Sendoso application settings.","cause":"Commonly caused by an incorrect `clientSecret`, an invalid `callbackURL` (which must exactly match the one registered with Sendoso), or network issues.","error":"Error: Failed to obtain access token"},{"fix":"Make sure you have `app.use(passport.initialize());` and `app.use(passport.session());` configured in your Express application middleware chain after session middleware.","cause":"The Passport middleware (`passport.initialize()` and `passport.session()`) has not been applied to the Express app, or Passport itself hasn't been imported.","error":"TypeError: Cannot read properties of undefined (reading 'authenticate')"}],"ecosystem":"npm","meta_description":null}