Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | import { PassportStrategy } from '@nestjs/passport'; import { Strategy, VerifyCallback } from 'passport-google-oauth20'; import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { AuthService } from '../auth.service'; @Injectable() export class GoogleStrategy extends PassportStrategy(Strategy, 'google') { constructor( private configService: ConfigService, private authService: AuthService, ) { super({ clientID: configService.get<string>('GOOGLE_CLIENT_ID'), clientSecret: configService.get<string>('GOOGLE_CLIENT_SECRET'), callbackURL: '/api/v1/auth/google/callback', scope: ['email', 'profile'], }); } async validate( accessToken: string, refreshToken: string, profile: any, done: VerifyCallback, ): Promise<any> { try { const result = await this.authService.googleLogin(profile); done(null, result); } catch (error) { done(error, null); } } } |