As seen here:
https://developers.google.com/accounts/docs/OpenID
Google is deprecating OpenId in favor of OAuth2
So I tried to use the following Google strategy locally to use OAuth2:
google: {
name: 'Google',
protocol: 'oauth2',
scope: ["https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile"],
strategy: require('passport-google-oauth').Strategy,
options: {
clientID: 'MY_CLIENT_ID',
clientSecret: 'MY_CLIENT_SECRET'
}
}
It didn't work at first because in passport-google-oauth / lib / passport-google-oauth / index.js
we see this:
/**
- Expose constructors.
*/
exports.Strategy =
exports.OAuthStrategy = OAuthStrategy;
exports.OAuth2Strategy = OAuth2Strategy;
When Passport uses the Strategy object, it gets OAuthStrategy by default.
In order to make a quick and dirty patch to make it work locally, I just forced Strategy to use OAuth2 like so:
/**
- Expose constructors.
*/
exports.Strategy = OAuth2Strategy;
exports.OAuthStrategy = OAuthStrategy;
exports.OAuth2Strategy = OAuth2Strategy;
Works great locally...
A week later, I tried to deploy to Heroku. My sails app wouldn't lift...
After a while, I remembered I had to change the Strategy to use OAuth2.
Since my app is rebuilt on Heroku from its dependencies, I now have the ORIGINAL passport-google-oauth, which doesn't work for OAuth2...
Maybe @jaredhanson could have a look at this. Everyone would benefit from this fix.
Thanks,
Luc