From 15f06f254f85290f03f8843ef8ab7c5a5a746b6b Mon Sep 17 00:00:00 2001 From: neyric Date: Sat, 26 Feb 2011 15:01:54 +0100 Subject: [PATCH] Follow 302 redirects with "Location" header --- lib/oauth.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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); }