seneca-google-auth

raw JSON →
1.0.0 verified Sat Apr 25 auth: no javascript maintenance

A Seneca.js plugin for Google OAuth2 authentication, used as a service provider with seneca-auth. Version 1.0.0 is the current stable release, last updated in 2016. It wraps PassportJS Google strategy and provides a default action to transform Google login data. Key differentiator: integrates with Seneca microservices framework, allowing custom overrides of user data preparation. Requires seneca-auth and seneca as peer dependencies. No active maintenance, but functional for legacy Seneca applications.

error Error: Cannot find module 'seneca-google-auth'
cause Package not installed or not in node_modules.
fix
npm install seneca-google-auth
error Seneca: Plugin not found: google-auth
cause Plugin not registered before use.
fix
Ensure require('seneca-google-auth') or require('seneca-google-auth')() before seneca.use.
error TypeError: Cannot read properties of undefined (reading 'clientID')
cause Options object missing clientID property.
fix
Provide clientID in the Google service options.
deprecated Package not updated since 2016; may not work with modern Seneca versions (>3).
fix Consider alternative auth plugins or upgrade to maintained fork.
gotcha Plugin name when using seneca.use is 'google-auth', not 'seneca-google-auth'.
fix Call seneca.use('google-auth', options).
breaking Requires seneca-auth as peer; missing dependency causes silent failures.
fix Install seneca-auth: npm install seneca-auth.
gotcha Options must include both clientID and clientSecret; missing one results in runtime error.
fix Provide both clientID and clientSecret in options.
gotcha Default callback URL is /auth/google/callback; if route conflicts, override via callbackUrl option.
fix Set callbackUrl in options to a unique path.
npm install seneca-google-auth
yarn add seneca-google-auth
pnpm add seneca-google-auth

Initializes Seneca with local and Google authentication using environment variables for credentials.

const seneca = require('seneca')({ log: 'silent' });
const senecaAuth = require('seneca-auth');
require('seneca-google-auth');

seneca.use(senecaAuth, {
  service: {
    local: {},
    google: {
      clientID: process.env.GOOGLE_CLIENT_ID ?? '',
      clientSecret: process.env.GOOGLE_CLIENT_SECRET ?? '',
      urlhost: process.env.HOST ?? 'http://localhost:3000',
      serviceParams: { scope: ['profile', 'email'] }
    }
  }
});

seneca.ready(() => {
  console.log('Google auth plugin ready');
});