diff --git a/lib/oauth2.js b/lib/oauth2.js index 319fb03..4cfe290 100644 --- a/lib/oauth2.js +++ b/lib/oauth2.js @@ -29,13 +29,16 @@ exports.OAuth2.prototype._getAccessTokenUrl= function() { exports.OAuth2.prototype._request= function(method, url, headers, post_body, access_token, callback) { + var http_library= https; var creds = crypto.createCredentials({ }); var parsedUrl= URL.parse( url, true ); if( parsedUrl.protocol == "https:" && !parsedUrl.port ) { parsedUrl.port= 443; - http_library = https; - } else { - http_library = http; + } + + // As this is OAUth2, we *assume* https unless told explicitly otherwise. + if( parsedUrl.protocol != "https:" ) { + http_library= http; } var realHeaders= {};