Skip Menu |

This queue is for tickets about the Net-OAuth-Simple CPAN distribution.

Report information
The Basics
Id: 60438
Status: open
Priority: 0/
Queue: Net-OAuth-Simple

People
Owner: Nobody in particular
Requestors: olaf [...] wundersolutions.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.5
Fixed in: (no value)



Subject: GET is hard coded into request methods
I'm currently using this module to connect to the FreshBooks.com API. They, for whatever reason, are insisting on POST requests in some cases where GET is hard coded into the module. Specifically, FreshBooks requires POST for the access and request tokens. In order to make this work, POST also needs to be allowed for in _make_request at line 719: if ('GET' eq $method || 'PUT' eq $method) { I'm not sure of a clean way to have the user specify GET or POST with the way things are currently set up, but I wanted to see if you were open to accepting a patch before I dig too deeply. Best, Olaf
On Tue Aug 17 17:18:51 2010, OALDERS wrote: Show quoted text
> I'm currently using this module to connect to the FreshBooks.com API. > They, for whatever reason, are insisting on POST requests in some cases > where GET is hard coded into the module. > > Specifically, FreshBooks requires POST for the access and request > tokens. In order to make this work, POST also needs to be allowed for > in _make_request at line 719: > > if ('GET' eq $method || 'PUT' eq $method) {
Notice that just after that line there's an 'else' statement. You can make restricted POST requests by Just calling make_restricted_request with a 'POST' param. For example in Net::FireEagle the method 'update_location' does sub update_location { my $self = shift; my $location = shift; my %opts = @_; my %extras = $self->_munge('address', $location); my $url = $UPDATE_API_URL; $url .= '.'.$opts{format} if defined $opts{format}; return $self->make_restricted_request($url, 'POST', %extras); } Let me know if that's not working for you though and I'll fix it.
On Tue Aug 17 17:39:40 2010, SIMONW wrote: Show quoted text
> On Tue Aug 17 17:18:51 2010, OALDERS wrote:
> > I'm currently using this module to connect to the FreshBooks.com
> API.
> > They, for whatever reason, are insisting on POST requests in some
> cases
> > where GET is hard coded into the module. > > > > Specifically, FreshBooks requires POST for the access and request > > tokens. In order to make this work, POST also needs to be allowed
> for
> > in _make_request at line 719: > > > > if ('GET' eq $method || 'PUT' eq $method) {
> > Notice that just after that line there's an 'else' statement.
True, but in the case of POST, it's not doing what I need it to do. In my case, I'm overriding request_request_token(). The only change I've made is to use POST rather than GET. If I don't include POST in the IF statement, I get: POST on https://netfreshbooksapi.freshbooks.com/oauth/oauth_request.php failed: 400 Bad Request Missing required parameter: oauth_consumer_key If I add POST to the if condition, it works beautifully. Show quoted text
> > You can make restricted POST requests by Just calling > make_restricted_request with a 'POST' > param. For example in Net::FireEagle the method 'update_location' does > > > sub update_location { > my $self = shift; > my $location = shift; > my %opts = @_; > > my %extras = $self->_munge('address', $location); > > my $url = $UPDATE_API_URL; > $url .= '.'.$opts{format} if defined $opts{format}; > > return $self->make_restricted_request($url, 'POST', %extras); > } >
Thanks -- that's a good example. It's just that the issues I'm seeing are *before* I have all of the tokens. My total changes are: adding POST to the if condition in _make_request and changing GET to POST in request_request_token() and request_access_token() So, that works for me and it's actually a solution that (I think) I can live with, but it really duplicates a lot of code that I'm not sure I want as baggage in case the internals of Net::OAuth::Simple change in future. This could maybe be fixed with accessors like request_access_token_method() and request_request_token_method() which would accept GET or POST. Those are ugly names, but off the top of my head something along those lines might work? Basically, just a little bit of flexibility around GET and POST would go a long way, I think. Best, Olaf
On Wed Aug 18 16:14:40 2010, OALDERS wrote: Show quoted text
> Basically, just a little bit of flexibility around GET and POST would go > a long way, I think.
Ah, I see the problem now. I'll try and get a fix out this weekend.
On Fri Aug 20 20:07:38 2010, SIMONW wrote: Show quoted text
> Ah, I see the problem now. I'll try and get a fix out this weekend.
I'm waiting on a freshbooks OAuth consumer key and secret but can you try out the latest version of SVN from https://svn.unixbeard.net/simon/Net-OAuth-Simple/trunk Thanks! Simon
On Fri Aug 20 20:34:48 2010, SIMONW wrote: Show quoted text
> On Fri Aug 20 20:07:38 2010, SIMONW wrote:
> > Ah, I see the problem now. I'll try and get a fix out this weekend.
> > I'm waiting on a freshbooks OAuth consumer key and secret but can you > try out the latest > version of SVN from > > https://svn.unixbeard.net/simon/Net-OAuth-Simple/trunk
Excellent! I will try this out at $work on Monday. The FreshBooks approval took about 4 business days in my case. No idea why, really. I'll let you know how I make out. Thanks again for making these changes.
On Fri Aug 20 21:28:07 2010, OALDERS wrote: Show quoted text
> On Fri Aug 20 20:34:48 2010, SIMONW wrote:
> > On Fri Aug 20 20:07:38 2010, SIMONW wrote:
> > > Ah, I see the problem now. I'll try and get a fix out this weekend.
> > > > I'm waiting on a freshbooks OAuth consumer key and secret but can you > > try out the latest > > version of SVN from > > > > https://svn.unixbeard.net/simon/Net-OAuth-Simple/trunk
> > Excellent! I will try this out at $work on Monday. The FreshBooks > approval took about 4 business days in my case. No idea why, really. > I'll let you know how I make out. Thanks again for making these changes. > >
Just tested the SVN checkout. Works beautifully for me. Thanks very much!
On Mon Aug 23 16:34:38 2010, OALDERS wrote: Show quoted text
> On Fri Aug 20 21:28:07 2010, OALDERS wrote:
> > On Fri Aug 20 20:34:48 2010, SIMONW wrote:
> > > On Fri Aug 20 20:07:38 2010, SIMONW wrote:
> > > > Ah, I see the problem now. I'll try and get a fix out this weekend.
> > > > > > I'm waiting on a freshbooks OAuth consumer key and secret but can you > > > try out the latest > > > version of SVN from > > > > > > https://svn.unixbeard.net/simon/Net-OAuth-Simple/trunk
> > > > Excellent! I will try this out at $work on Monday. The FreshBooks > > approval took about 4 business days in my case. No idea why, really. > > I'll let you know how I make out. Thanks again for making these
changes. Show quoted text
> > > >
> > Just tested the SVN checkout. Works beautifully for me. Thanks very
much! No pressure from here, but do you have any idea when you may be able to release the patched version? I have some code in Net::Freshbooks::API which will depend on it. Thanks, Olaf