google-auth-nestjs
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

google-auth-nestjs

Description

Google login package for NestJs

Instalation

yarn add google-auth-nestjs

Quick Start

  1. Create your Google app and get your credentials (clientId and clientSecret) from Google Cloud panel.

  2. Import GoogleAuthModule on your NestJs module and use forRoot or forRootAsync static methods for initial configuration (configure using your clientId and clientSecret from Google Cloud panel).

import { GoogleAuthModule } from 'google-auth-nestjs';

@Module({
  imports: [
    GoogleAuthModule.forRoot({
      clientId: 'your-facebook-clientid',
      clientSecret: 'your-facebook-client-secret',
    }),
  ],
})
export class AppModule { }
  1. Import GoogleAuthService on your service or controller and use getUserData method to get user's information from Google.
import { GoogleAuthService } from 'google-auth-nestjs';

@Injectable()
export class AppService {

  constructor(private readonly service: GoogleAuthService) { }
  
  async getGoogleUser(accessToken: string): Promise<GoogleUserData> {
    return await this.service.getUserData(accessToken);
  }
}
  • To call getUserData method you have to pass the accessToken (sent from front-end login method).

Readme

Keywords

Package Sidebar

Install

npm i google-auth-nestjs

Weekly Downloads

450

Version

0.0.4

License

MIT

Unpacked Size

219 kB

Total Files

40

Last publish

Collaborators

  • iloginow