Skip to content

Instantly share code, notes, and snippets.

@christianstrang
Created July 9, 2019 08:05
Show Gist options
  • Save christianstrang/e5342f28a85711dd5bbc64276f2adae2 to your computer and use it in GitHub Desktop.
Save christianstrang/e5342f28a85711dd5bbc64276f2adae2 to your computer and use it in GitHub Desktop.
SailsJS GoogleStrategy for Passport
'use strict';
var passport = require('passport'),
GoogleStrategy = require('passport-google-oauth20').Strategy;
//var verifyHandler = function(req, token, tokenSecret, profile, done) {
var verifyHandler = function (accessToken, refreshToken, profile, cb, done) {
var data = {
id: cb.id,
name: cb.displayName,
email: cb.emails[0].value,
emailVerified: cb.emails[0].verified
};
return done(null, data);
};
passport.use(new GoogleStrategy({
clientID: YOUR_CLIENT_ID,
clientSecret: YOUR_CLIENT_SECRET,
callbackURL: 'http://localhost:1337/api/v1/auth/google/callback',
passReqToCallback: true
}, verifyHandler));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment