You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
924 B

import { Strategy, Profile, StrategyOptions, AuthenticateOptionsGoogle } from 'passport-google-oauth20';
import { Router } from 'express'
import passport from 'passport'
import genericStrategy from '../strategy'
const strategyOptions: StrategyOptions = {
clientID: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
callbackURL: '/auth/google/redirect',
}
export function googleStrategy() {
// @ts-ignore: No overload matches this call.
return new Strategy(strategyOptions, genericStrategy<Profile>('google'));
}
export const googleRouter = Router()
const googleAuthenticateOptions: AuthenticateOptionsGoogle = {
scope: ['email', 'profile']
}
googleRouter.get('/google', passport.authenticate('google', googleAuthenticateOptions));
googleRouter.get('/google/redirect',
passport.authenticate('google', { successRedirect: '/museo', failureRedirect: '/' }));