title: Nest.js Passport.js Google conflicts with Apple
body: <p>I have created auth for application by google (passport-google-oauth20) and apple (passport-appleid). When i try to invoke GET google-sign-in, I have the following error</p>
  <pre><code> [Nest] 987  - 07/22/2022, 9:49:18 AM   ERROR [ExceptionsHandler] Cannot read properties of undefined (reading 'callbackURL')
   TypeError: Cannot read properties of undefined (reading 'callbackURL')
       at GoogleStrategy.OAuth2Strategy.authenticate (/home/node/app/node_modules/passport-appleid/lib/strategy.js:76:59)
       at attempt (/home/node/app/node_modules/passport/lib/middleware/authenticate.js:369:16)
       at authenticate (/home/node/app/node_modules/passport/lib/middleware/authenticate.js:370:7)
       at /home/node/app/node_modules/@nestjs/passport/dist/auth.guard.js:96:3
       at new Promise (&lt;anonymous&gt;)
       at /home/node/app/node_modules/@nestjs/passport/dist/auth.guard.js:88:83
       at MixinAuthGuard.&lt;anonymous&gt; (/home/node/app/node_modules/@nestjs/passport/dist/auth.guard.js:49:36)
       at Generator.next (&lt;anonymous&gt;)
       at fulfilled (/home/node/app/node_modules/@nestjs/passport/dist/auth.guard.js:17:58)
       at processTicksAndRejections (node:internal/process/task_queues:96:5)
  </code></pre>
  <p>If i commented Apple Strategy in user module, everything work fine.
  I can't understand why GoogleStrategy.OAuth2Strategy.authenticate go to the appleid packages
  And If I use only Google Strategy or only Apple Strategy everything works.</p>
  <pre><code>  @UseGuards(AuthGuard('google'))
    @ApiOperation({ summary: 'google sign in' })
    @Get('google-sign-in')
    public async signInWithGoogle(@Req() req: any) {
      return req.user;
    }
  
    @UseGuards(AuthGuard('google'))
    @ApiOperation({ summary: 'google redirect' })
    @Get('auth/google/redirect')
    public async signInWithGoogleRedirect(@Req() req: any) {
      return this.userService.socialSignIn(req.user);
    }
  
    @UseGuards(AuthGuard('apple'))
    @ApiOperation({ summary: 'apple sign in' })
    @Get('apple-sign-in')
    public async signInWithApple(@Req() req: any) {
      return req.user;
    }
  
    @UseGuards(AuthGuard('apple'))
    @ApiOperation({ summary: 'apple redirect' })
    @Get('apple/redirect')
    public async signInWithAppleRedirect(@Req() req: any) {
      return this.userService.socialSignIn(req.user);
    }
  </code></pre>
  <pre><code>import { Injectable } from '@nestjs/common';
  import { PassportStrategy } from '@nestjs/passport';
  import { Profile } from 'passport';
  import { Strategy, VerifyCallback } from 'passport-google-oauth20';
  import { RegisteredPlatformsEnum } from 'src/_enum/registered-platforms.enum';
  import { ConfigService } from '../config.services';
  
  @Injectable()
  export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
    constructor(configService: ConfigService) {
      super({
        clientID: configService.get('GOOGLE_AUTH_CLIENT_ID'),
        clientSecret: configService.get('GOOGLE_AUTH_CLIENT_SECRET'),
        callbackURL: configService.get('GOOGLE_AUTH_CALLBACK_URL'),
        scope: ['email', 'profile'],
      });
    }
  
    public async validate(
      accessToken: string,
      refreshToken: string,
      profile: Profile,
      done: VerifyCallback,
    ): Promise&lt;any&gt; {
      const { name, emails } = profile;
      const [userEmail] = emails;
  
      const user = {
        email: userEmail.value,
        name: name.givenName,
        registeredPlatform: RegisteredPlatformsEnum.GOOGLE,
        accessToken,
      };
      done(null, user);
    }
  }
  
  </code></pre>
  <pre><code>import path from 'path';
  
  import { Injectable } from '@nestjs/common';
  import { PassportStrategy } from '@nestjs/passport';
  import { Profile } from 'passport';
  import { Strategy, VerifyCallback } from 'passport-appleid';
  import { RegisteredPlatformsEnum } from 'src/_enum/registered-platforms.enum';
  import { ConfigService } from '../config.services';
  
  @Injectable()
  export class AppleStrategy extends PassportStrategy(Strategy, 'apple') {
    constructor(configService: ConfigService) {
      super({
        clientID: configService.get('APPLE_AUTH_CLIENT_ID'),
        callbackURL: configService.get('APPLE_AUTH_CALLBACK_URL'),
        teamId: configService.get('APPLE_AUTH_TEAM_ID'),
        keyIdentifier: configService.get('APPLE_AUTH_KEY_IDENTIFIER'),
        privateKeyPath: path.join(
          __dirname,
          `./AuthKey_${configService.get('APPLE_AUTH_KEY_IDENTIFIER')}.p8`,
        ),
      });
    }
  
    public async validate(
      accessToken: string,
      refreshToken: string,
      profile: Profile,
      done: VerifyCallback,
    ): Promise&lt;any&gt; {
      const { name, emails } = profile;
      const [userEmail] = emails;
      const user = {
        email: userEmail.value,
        name: name.givenName,
        registeredPlatform: RegisteredPlatformsEnum.APPLE,
        accessToken,
      };
      done(null, user);
    }
  }
  
  </code></pre>
  <pre><code>import { Module, forwardRef, Logger } from '@nestjs/common';
  import { TypeOrmModule } from '@nestjs/typeorm';
  
  import { AppModule } from '../../app.module';
  import { ConfigService } from '../../services/config.services';
  import { UserService } from './services/users.service';
  import { UserController } from './user.controller';
  import { UserEntity } from '../../model/user.entity';
  import { EmailService } from '../../services/email.service';
  import { UserRepository } from 'src/repositories/user.repository';
  import { GoogleStrategy } from 'src/services/strategy/google-strategy';
  import { AppleStrategy } from 'src/services/strategy/apple-strategy';
  
  @Module({
    imports: [
      forwardRef(() =&gt; AppModule),
      TypeOrmModule.forFeature([UserEntity, UserRepository]),
    ],
    controllers: [UserController],
    providers: [
      Logger,
      UserService,
      ConfigService,
      EmailService,
  
      // passport strategies
      AppleStrategy,
      GoogleStrategy,
    ],
    exports: [UserService],
  })
  export class UserModule {}
  
  </code></pre>