Skip Menu |

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

Report information
The Basics
Id: 83901
Status: new
Priority: 0/
Queue: Net-OAuth-Simple

People
Owner: Nobody in particular
Requestors: realflash.uk [...] googlemail.com
Cc:
AdminCc:

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



Subject: Add 'return_response_on_error' setting
Dear Simon, I am using Net::OAuth::Simple to retrieve information from multiple JSON data sources. Some sources return an HTTP error code, with additional error description in the attached content (still in JSON). See the attachment for an example. It gets returned along with HTTP code 400. For my application this 400 error is non-fatal for certain conditions, but as of today I cannot access the content of the response to find out, as I only have the option of croaking or returning undef. Please can you add a 'return_response_on_error' setting, that would delegate the responsibility of checking for errors to me (patch attached). A side advantage is that the behaviour will then match LWP::UserAgent, so that I can use the same code to retrieve non authenticated sources via LWP and authenticated sources via NOS. Thanks. Ian Gibbs
Subject: 569474089.JSON
{"Request":"https:\/\/api.trademe.co.nz\/v1\/Listings\/569474089.JSON?","ErrorDescription":"Classified has expired"}
Subject: return_response_on_error.patch
*** Simple.pm 2010-08-04 20:56:57.000000000 +0100 --- Simple.pm.modified 2013-03-12 11:27:12.215564024 +0000 *************** *** 726,732 **** my $req = HTTP::Request->new( $method => $req_url, @args); my $response = $self->{browser}->request($req); return $self->_error("$method on $request failed: ".$response->status_line) ! unless ( $response->is_success ); return $response; } --- 726,732 ---- my $req = HTTP::Request->new( $method => $req_url, @args); my $response = $self->{browser}->request($req); return $self->_error("$method on $request failed: ".$response->status_line) ! unless ( $response->is_success || $self->{return_response_on_error} ); return $response; } *************** *** 811,820 **** =head1 ERROR HANDLING ! Originally this module would die upon encountering an error (inheriting behaviour ! from the original Yahoo! code). ! This is still the default behaviour however if you now pass return_undef_on_error => 1 --- 811,822 ---- =head1 ERROR HANDLING ! The default behaviour of this module is to die upon encountering an error (inheriting behaviour ! from the original Yahoo! code). The following alternatives are available. ! =head2 return_undef_on_error ! ! If you pass return_undef_on_error => 1 *************** *** 822,827 **** --- 824,843 ---- The error message is accessible via the C<last_error()> method. + =head2 return_response_on_error + + If you pass + + return_response_on_error => 1 + + into the constructor then all methods that make a call to a remote server will return + the response of the server whether or not it was successful. You will need to check + the response for yourself with $response->is_success() or similar. Other methods will + continue to die unless return_undef_on_error is defined. This setting overrides + return_undef_on_error in respect of the methods it applies to. You might want to + leave this off for token manipulation methods, and only use it for + C<make_restricted_request()>. + =head1 GOOGLE'S SCOPE PARAMETER Google's OAuth API requires the non-standard C<scope> parameter to be set