diff --git a/lib/oauth.js b/lib/oauth.js index c662082..3ccdba6 100644 --- a/lib/oauth.js +++ b/lib/oauth.js @@ -309,7 +309,13 @@ exports.OAuth.prototype._performSecureRequest= function( oauth_token, oauth_toke }); response.on('end', function () { if( response.statusCode != 200 ) { - callback({ statusCode: response.statusCode, data: data }); + // Follow 302 redirects with Location HTTP header + if(response.statusCode == 302 && response.headers.location) { + self._performSecureRequest( oauth_token, oauth_token_secret, method, response.headers.location, extra_params, post_body, post_content_type, callback); + } + else { + callback({ statusCode: response.statusCode, data: data }, data, response); + } } else { callback(null, data, response); }