npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

googleauthsso

v1.1.4

Published

A Passport.js Google OAuth2.0 strategy service

Downloads

31

Readme

googleauthsso

Description

A Passport.js Google OAuth2.0 strategy service.

Installation

npm install googleauthsso

Usage

const googleOAuth20Service = require('googleauthsso');

const authArgs = {
  serverInstance: app, // Express app instance
  passport: passport, // Passport instance
  config: {
    GOOGLE_CLIENT_ID: 'your-client-id',
    GOOGLE_CLIENT_SECRET: 'your-client-secret',
    GOOGLE_CALLBACK_URL: 'your-callback-url',
    SESSION_SECRET: 'your-session-secret'
  },
  redirection: {
    success: '/dashboard', // Successful login redirect
    failure: '/' // Failed login redirect
  },
  dboperation: async () => {
    // Database operation for finding/creating a user
  }
};

googleOAuth20Service(authArgs);

Configuration

Ensure the following environment variables are set

  • GOOGLE_CLIENT_ID
  • GOOGLE_CLIENT_SECRET
  • GOOGLE_CALLBACK_URL
  • SESSION_SECRET

or

you can also setup it in by creating config obj with creadentials like

let config={
    GOOGLE_CLIENT_ID:"your google client id",////you can get it from google developers console login
    GOOGLE_CLIENT_SECRET:"your google client secret", //you can get it from google developers console login
    GOOGLE_CALLBACK_URL:"callback url", // it would be like "http://localhost:3000/auth/google/callback"
    SESSION_SECRET:"user defined secret" //can be anything according to user
}

Example


const express = require("express");
const passport = require("passport");
const googleOAuth20Service = require("googleauthsso");
const dotenv = require("dotenv");

dotenv.config();

const app = express();
const PORT = process.env.PORT || 3000;

// Initialize Google OAuth 2.0 service
googleOAuth20Service({
  serverInstance: app,
  passport: passport,
  config: {
    GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID,
    GOOGLE_CLIENT_SECRET: process.env.GOOGLE_CLIENT_SECRET,
    GOOGLE_CALLBACK_URL: process.env.GOOGLE_CALLBACK_URL,
    SESSION_SECRET: process.env.SESSION_SECRET,
  },
  redirection: {
    success: "/dashboard",
    failure: "/login",
  },
  //dboperation is optional field
  dboperation: async () => {
    // Implement your database operation here
    // E.g., find or create a user in your database
    return null; // Replace with actual user object
  },
});

// Start the server
app.listen(PORT, () => {
  console.log(`Server is running on http://localhost:${PORT}`);
});

Notes:

  1. Customization: Make sure to replace placeholder values like your_google_client_id, your_google_client_secret, and your_session_secret,callback url with actual values.
  2. Database Operation: The dboperation function in the example is a placeholder for your database logic. You should implement this according to your application's requirements.
  3. License: If you have a specific license for your package, include it in the LICENSE file and reference it in the README.

Feel free to modify any sections as per your needs!

if you have any suggestion so you can email shivasoni8528@gmail

Author

Shiva Soni

License

MIT