2025-04-16 10:49:46 -07:00
|
|
|
require('dotenv').config();
|
|
|
|
|
|
|
|
|
|
const GoogleStrategy = require("passport-google-oauth20").Strategy;
|
|
|
|
|
const passport = require("passport");
|
|
|
|
|
|
|
|
|
|
passport.use(
|
|
|
|
|
new GoogleStrategy(
|
|
|
|
|
{
|
2025-04-21 17:14:11 -07:00
|
|
|
clientID: process.env.GOOGLE_CLIENT_ID,
|
|
|
|
|
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
|
|
|
|
|
callbackURL: process.env.GOOGLE_CALLBACK_URL,
|
2025-04-16 10:49:46 -07:00
|
|
|
scope: ["profile", "email"],
|
|
|
|
|
},
|
|
|
|
|
function (accessToken, refreshToken, profile, callback) {
|
|
|
|
|
|
|
|
|
|
// Save the user info to your DB here if still not yet saved
|
|
|
|
|
// Example of what profile might contain:
|
|
|
|
|
// {
|
|
|
|
|
// "id": "112233445566778899",
|
|
|
|
|
// "displayName": "John Doe",
|
|
|
|
|
// "emails": [{ "value": "john.doe@gmail.com" }],
|
|
|
|
|
// "photos": [{ "value": "https://.../photo.jpg" }]
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
callback(null, profile);
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
passport.serializeUser((user, done) => {
|
|
|
|
|
done(null, user);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
passport.deserializeUser((user, done) => {
|
|
|
|
|
done(null,user);
|
|
|
|
|
});
|