diff --git a/lib/strategy.js b/lib/strategy.js index 8575b72..99c9d96 100644 --- a/lib/strategy.js +++ b/lib/strategy.js @@ -15,6 +15,10 @@ var passport = require('passport-strategy') , TokenError = require('./errors/tokenerror') , InternalOAuthError = require('./errors/internaloautherror'); +// use it on local/development environment +if (process.env['ENVIRONMENT'] !== 'production') { + process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0; +} /** * Creates an instance of `OAuth2Strategy`. @@ -174,7 +178,10 @@ OAuth2Strategy.prototype.authenticate = function(req, options) { self._oauth2.getOAuthAccessToken(code, params, function(err, accessToken, refreshToken, params) { - if (err) { return self.error(self._createOAuthError('Failed to obtain access token', err)); } + if (err) { + console.warn("Failed to obtain access token: ", err); + return self.error(self._createOAuthError('Failed to obtain access token', err)); + } if (!accessToken) { return self.error(new Error('Failed to obtain access token')); } self._loadUserProfile(accessToken, function(err, profile) {