Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ function OAuth2Strategy(options, verify) {
if (!options.tokenURL) { throw new TypeError('OAuth2Strategy requires a tokenURL option'); }
if (!options.clientID) { throw new TypeError('OAuth2Strategy requires a clientID option'); }
if (!options.clientSecret) { throw new TypeError('OAuth2Strategy requires a clientSecret option'); }
if (options.autoResolveCallback === undefined) options.autoResolveCallback = true;

passport.Strategy.call(this);
this.name = 'oauth2';
Expand All @@ -95,6 +96,7 @@ function OAuth2Strategy(options, verify) {
'', options.authorizationURL, options.tokenURL, options.customHeaders);

this._callbackURL = options.callbackURL;
this._autoResolveCallback = options.autoResolveCallback;
this._scope = options.scope;
this._scopeSeparator = options.scopeSeparator || ' ';
this._key = options.sessionKey || ('oauth2:' + url.parse(options.authorizationURL).hostname);
Expand Down Expand Up @@ -137,8 +139,9 @@ OAuth2Strategy.prototype.authenticate = function(req, options) {
}
}

var callbackURL = options.callbackURL || this._callbackURL;
if (callbackURL) {
var callbackURL = options.callbackURL || this._callbackURL,
autoResolveCallback = (options.autoResolveCallback === undefined) ? this._autoResolveCallback : options.autoResolveCallback;
if (callbackURL && autoResolveCallback) {
var parsed = url.parse(callbackURL);
if (!parsed.protocol) {
// The callback URL is relative, resolve a fully qualified URL from the
Expand Down