Registry / security / social-auth-bxcore

social-auth-bxcore

JSON →
library1.0.4jsnpmunverified

Social-auth-express is a PassportJS wrapper that simplifies adding social login (Facebook, Twitter, Google, GitHub, LinkedIn, Instagram, VK, Foursquare, Imgur, Meetup, Telegram) to Express apps. Version 1.0.4 stable, low release cadence. Differentiators: centralized onAuth callback, pre-parsed profile data, unique property detection, and minimal boilerplate vs raw PassportJS. Supports ESM via import but primarily CommonJS. No TypeScript types included; requires manual session setup.

npm install social-auth-bxcore
INSTALL
IMPORT
SIG · SOCIAL-AUTH-BXCORE
S
social-auth-bxcore
securityjavascriptv1.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import SocialAuth from 'social-auth-express'
const { SocialAuth } = require('social-auth-express')
Default export is a constructor. CommonJS require returns the constructor directly. Named import fails.
SocialAuth (constructor)
const SocialAuth = require('social-auth-express')
import socialAuth from 'social-auth-express'
CommonJS require works; ESM import is also supported, but ensure no named import.
socialAuth.use()
socialAuth.use({ facebook: { settings: {...}, url: {...} } })
socialAuth.use('facebook', { settings: {...}, url: {...} })
The use() method expects a single object with provider keys, not separate arguments.

Sets up Express with sessions, initializes social-auth-express with Google OAuth, and configures routes.

import express from 'express'; import SocialAuth from 'social-auth-express'; import session from 'express-session'; const app = express(); app.use(session({ secret: 'your-secret', resave: true, saveUninitialized: true })); const socialAuth = new SocialAuth({ app, url: 'http://localhost:3000', onAuth: (req, type, uniqueProperty, accessToken, refreshToken, profile, done) => { // Find or create user based on profile and uniqueProperty const user = { id: profile.id, name: profile.displayName }; done(null, user); } }); socialAuth.use({ google: { settings: { clientID: process.env.GOOGLE_CLIENT_ID ?? '', clientSecret: process.env.GOOGLE_CLIENT_SECRET ?? '' }, url: { auth: '/auth/google', callback: '/auth/google/callback', success: '/dashboard', fail: '/login' } } }); app.listen(3000, () => console.log('Server running on http://localhost:3000'));
Debug
Known issues
gotchaMissing express-session middleware will cause silent failure or errors in Passport serialize/deserialize.
fix
Install and use express-session (or compatible session middleware) before initializing social-auth-express.
affects: >=0.0.0
gotchaThe 'url' option must include protocol (e.g., 'http://localhost:3000'), not just domain.
fix
Provide full URL with protocol and port, like 'http://localhost:3000'.
affects: >=0.0.0
breakingIn v1.0.0, the constructor parameter 'app' changed from Express instance to object with { app, url, onAuth }. Older code using 'new SocialAuth(app, url)' will break.
fix
Update constructor call to object syntax: new SocialAuth({ app, url, onAuth }).
affects: <1.0.0
deprecatedFacebook OAuth requires specifying strategy.profileURL and profileFields in v2.6+; default may not work.
fix
Explicitly set 'strategy.profileURL' to 'https://graph.facebook.com/v2.6/me' and 'profileFields' as shown in docs.
affects: >=1.0.0
gotchaThe 'onAuth' callback's 'uniqueProperty' can be 'id', 'ID', etc., depending on provider; your user lookup must handle this.
fix
Use the 'uniqueProperty' argument to dynamically determine which field from 'profile' to use for user identification.
affects: >=0.0.0
Errors
Common errors & fixes
Error: OAuthCallback: failed to obtain access token
Invalid clientID/clientSecret or mismatched redirect URI in provider app settings.
fix
Verify that the callback URL in your provider app (e.g., 'http://localhost:3000/auth/google/callback') matches exactly the 'url.callback' property in socialAuth.use().
Cannot read property 'use' of undefined
Attempting to call socialAuth.use() without properly initializing socialAuth with 'new'.
fix
Ensure you use 'new SocialAuth({...})' and assign result to a variable before calling .use().
TypeError: socialAuthClass is not a constructor
Using named import or wrong require path (e.g., 'social-auth-core' instead of 'social-auth-express').
fix
Use correct package name 'social-auth-express' and import default: 'import SocialAuth from 'social-auth-express'' or 'const SocialAuth = require('social-auth-express')'.
Failed to serialize user into session
Missing passport.serializeUser or express-session setup.
fix
Add session middleware and passport serialization. Example: passport.serializeUser((user, done) => done(null, user));
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies
passportrequiredCore authentication middleware used internally
expressrequiredRequired as peer dependency for Express integration
Agent activity
18 hits · last 30 days
node
18
Resources
social-auth-bxcore — npm install social-auth-bxcore · libregistry