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 🙏

© 2025 – Pkg Stats / Ryan Hefner

nestjs-google-oauth

v0.0.5

Published

[![NPM Version](https://img.shields.io/npm/v/nestjs-google-oauth.svg)](https://www.npmjs.com/package/nestjs-google-oauth) [![License](https://img.shields.io/npm/l/nestjs-google-oauth.svg)](https://github.com/mirzasaikatahmmed/nestjs-google-oauth/blob/main

Readme

NestJS Google OAuth

NPM Version License Build Status

A simple, robust, and easy-to-use NestJS package for integrating Google OAuth 2.0 authentication.

Features

  • 🚀 Easy Integration: Plug and play with your NestJS application.
  • 🔒 Secure: Built on top of passport-google-oauth20.
  • ⚙️ Configurable: Supports asynchronous configuration (e.g., using @nestjs/config).
  • 📦 Session Support: Built-in session serialization.
  • 🧩 Type Safe: Written in TypeScript with full type definitions.

Installation

npm install nestjs-google-oauth

(Note: All necessary dependencies like @nestjs/passport, passport, etc. are installed automatically)

Author

Usage

1. Configure Environment Variables

Create a .env file in your project root:

GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
GOOGLE_CALLBACK_URL=http://localhost:3000/auth/google/redirect

2. Import the Module

Import GoogleOauthModule in your AppModule. We recommend using registerAsync with @nestjs/config to securely load credentials.

import { Module } from '@nestjs/common';
import { GoogleOauthModule } from 'nestjs-google-oauth';
import { ConfigModule, ConfigService } from '@nestjs/config';

@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
    }),
    GoogleOauthModule.registerAsync({
      imports: [ConfigModule],
      useFactory: async (configService: ConfigService) => ({
        clientId: configService.get<string>('GOOGLE_CLIENT_ID'),
        clientSecret: configService.get<string>('GOOGLE_CLIENT_SECRET'),
        callbackUrl: configService.get<string>('GOOGLE_CALLBACK_URL'),
      }),
      inject: [ConfigService],
    }),
  ],
})
export class AppModule {}

3. Setup Session in main.ts

Ensure you configure express-session and passport in your main.ts file:

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import * as session from 'express-session';
import * as passport from 'passport';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  app.use(
    session({
      secret: 'your-secret-key', // Change this!
      resave: false,
      saveUninitialized: false,
    }),
  );

  app.use(passport.initialize());
  app.use(passport.session());

  await app.listen(3000);
}
bootstrap();

4. Test It!

Start your application and navigate to: http://localhost:3000/auth/google

You will be redirected to Google to sign in. Upon success, you will be redirected back to your callback URL (default: /auth/google/redirect) and receive the user profile data.

Configuration Options

The register and registerAsync methods accept the following options:

| Option | Type | Description | | --- | --- | --- | | clientId | string | Your Google Client ID. | | clientSecret | string | Your Google Client Secret. | | callbackUrl | string | The URL to redirect to after Google Login. |

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.