import { Injectable } from '@nestjs/common' ; import { PassportStrategy } from '@nestjs/passport' ; import { Strategy } from 'passport-google-oauth20' ; import { GoogleUserDto } from '../dto/google-user.dto' ; @ Injectable ( ) export class GoogleStrategy extends PassportStrategy ( Strategy , 'google' ) { constructor ( ) { super ( { clientID : process . env . GOOGLE_CLIENT_ID , clientSecret : process . env . GOOGLE_CLIENT_SECRET , callbackURL : process . env . SERVER_URL + '/api/auth/google/callback' , passReqToCallback : true , scope : [ 'profile' , 'email' ] , } ) ; } async validate ( request , accessToken , refreshToken , profile , done ) { const { emails } = profile ; const email = emails . filter ( ( mail ) => mail . value ) [ 0 ] . value ; const googleUserInfo = { email , profile } ; done ( null , googleUserInfo ) ; } }