parent
01871c2dfc
commit
7b77c76fb2
@ -0,0 +1,27 @@
|
|||||||
|
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: '/' }));
|
Loading…
Reference in new issue