Initial working google auth
This commit is contained in:
parent
fb52d49f74
commit
00a40f6bba
1058 changed files with 114441 additions and 0 deletions
36
auth-service/passport.js
Normal file
36
auth-service/passport.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
require('dotenv').config();
|
||||
|
||||
const GoogleStrategy = require("passport-google-oauth20").Strategy;
|
||||
const passport = require("passport");
|
||||
|
||||
passport.use(
|
||||
new GoogleStrategy(
|
||||
{
|
||||
clientID: process.env.CLIENT_ID,
|
||||
clientSecret: process.env.CLIENT_SECRET,
|
||||
callbackURL: "/auth/google/callback",
|
||||
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);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue