google-auth-nestjs
v0.0.4
Published
Google login package for NestJs
Downloads
14
Readme
google-auth-nestjs
Description
Google login package for NestJs
Instalation
yarn add google-auth-nestjs
Quick Start
Create your Google app and get your credentials (clientId and clientSecret) from Google Cloud panel.
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 { }
- 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).