Support for 301 Redirects #51

Open
bdickason opened this Issue Jul 3, 2011 · 2 comments

2 participants

@bdickason

I've been struggling with a really simple OAuth integration with the site Goodreads. They throw a 301 redirect when you hit /oauth/request_token before returning the oauthToken and oauthSecret. The app errors out currently because the oauth plugin only follows 302 redirects atm.

I've temporarily modified the oauth.js (line 360) with this hotfix but as I'm a neophyte programmer, I'm sure it's not the most efficient way to handle this:

else if(response.statusCode == 301 && response.headers && response.headers.location) {
self._performSecureRequest( oauth_token, oauth_token_secret, method, response.headers.location, extra_params, post_body, post_content_type, callback);
}

@ciaranj
Owner

Hmm technically a 301 should be verb aware , and make sure it was originally a GET that was made allowing a user to stop a POST to another location for example, but yes your solution is fine, if you want to submit a patch a long the lines of

else if( (response.statusCode == 301 || response.statusCode == 302) && response.headers && response.headers.location) {

I'll be happy to merge it in :)

@bdickason

Just submitted the pull request :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment