login via google on my meanjs website stopped working all of the sudden after three years, without any change to the code. The request sent:
/**
* Module dependencies
*/
var passport = require('passport'),
GoogleStrategy = require('passport-google-oauth').OAuth2Strategy,
users = require('../../controllers/users.server.controller');
module.exports = function (config) {
// Use google strategy
passport.use(new GoogleStrategy({
clientID: config.google.clientID,
clientSecret: config.google.clientSecret,
callbackURL: config.google.callbackURL,
passReqToCallback: true,
scope: ['profile', 'email']
},
function (req, accessToken, refreshToken, profile, done) {
// Set the provider data and include tokens
var providerData = profile._json;
providerData.accessToken = accessToken;
providerData.refreshToken = refreshToken;
// Create the user OAuth profile
var providerUserProfile = {
firstName: profile.name.givenName,
lastName: profile.name.familyName,
displayName: profile.displayName,
email: profile.emails[0].value,
username: profile.username,
profileImageURL: (providerData.picture) ? providerData.picture : undefined,
provider: 'google',
providerIdentifierField: 'id',
providerData: providerData
};
// Save the user OAuth profile
users.saveOAuthUserProfile(req, providerUserProfile, done);
}));
};
this successfuly redirects to google consent screen, after login the call back is fired:
passport.authenticate('google', {},function (err, user, info) {
if (err) {
console.log(err);
return res.redirect('/authentication/signin?err=' + encodeURIComponent(errorHandler.getErrorMessage(err)));
}
if (!user) {
return res.redirect('/authentication/signin');
}
.....
and returns the error "Failed to fetch user profile", this is the console.log of the err var:
{ InternalOAuthError: Failed to fetch user profile
at C:\Users\Administrator\Documents\printer\mean-printer\node_modules\passport-google-oauth20\lib\strategy.js:99:19
at ClientRequest.<anonymous> (C:\Users\Administrator\Documents\printer\mean-printer\node_modules\oauth\lib\oauth2.js
:162:5)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at TLSSocket.socketErrorListener (_http_client.js:401:9)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:66:8)
at _combinedTickCallback (internal/process/next_tick.js:139:11)
at process._tickDomainCallback (internal/process/next_tick.js:219:9)
name: 'InternalOAuthError',
message: 'Failed to fetch user profile',
oauthError: { Error: read ECONNRESET
at TLSWrap.onread (net.js:622:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' } }
Again saying, this started suddenly after working for 3 years. no code changes were made.
any ideas?
Cheers