import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { PassportStrategy } from '@nestjs/passport'; import { Strategy, VerifyCallback } from 'passport-google-oauth20'; @Injectable() export class GoogleStrategy extends PassportStrategy(Strategy, 'google') { constructor(configService: ConfigService) { super({ clientID: configService.get('GOOGLE_CLIENT_ID') || 'dummy', clientSecret: configService.get('GOOGLE_CLIENT_SECRET') || 'dummy', callbackURL: configService.get('GOOGLE_CALLBACK_URL'), scope: ['email', 'profile'], }); } async validate( accessToken: string, refreshToken: string, profile: any, done: VerifyCallback, ): Promise { const { id, displayName, emails } = profile; const user = { providerId: id, provider: 'google', email: emails?.[0]?.value, name: displayName, }; done(null, user); } }