Changelog:
* Added support for OAuth 1.0A - see POD section 'OAUTH 1.0A' for
details - Net::OAuth still defaults to 1.0 for now
Added the following POD regarding OAuth 1.0a spec support.
Best,
Keith
OAUTH 1.0A
Background:
http://mojodna.net/2009/05/20/an-idiots-guide-to-oauth-10a.html
http://oauth.googlecode.com/svn/spec/core/1.0a/drafts/3/oauth-core-1_...
Net::OAuth defaults to OAuth 1.0 spec compliance, and supports OAuth
1.0 Rev A with an optional switch:
use Net::OAuth
$Net::OAuth::PROTOCOL_VERSION = Net::OAuth::PROTOCOL_VERSION_1_0A;
It is recommended that any new projects use this switch if possible,
and existing projects move to supporting this switch as soon as
possible. Probably the easiest way for existing projects to do this is
to turn on the switch and run your test suite. The Net::OAuth
constructor will throw an exception where the new protocol parameters
(callback, callback_confirmed, verifier) are missing.
Internally, the Net::OAuth::Message constructor checks
$Net::OAuth::PROTOCOL_VERSION and attempts to load the equivalent
subclass in the Net::OAuth::V1_0A:: namespace. So if you instantiate a
Net::OAuth::RequestTokenRequest object, you will end up with a
Net::OAuth::V1_0A::RequestTokenRequest (a subclass of
Net::OAuth::RequestTokenRequest) if the protocol version is set to
PROTOCOL_VERSION_1_0A. You can also select a 1.0a subclass on a per-
message basis by passing
protocol_version => Net::OAuth::PROTOCOL_VERSION_1_0A
in the API parameters hash.
If you are not sure whether the entity you are communicating with is
1.0A compliant, you can try instantiating a 1.0A message first and
then fall back to 1.0 if that fails:
use Net::OAuth
$Net::OAuth::PROTOCOL_VERSION = Net::OAuth::PROTOCOL_VERSION_1_0A;
my $is_oauth_1_0 = 0;
my $response = eval{Net::OAuth->response('request token')-
>from_post_body($res->content)};
if ($@) {
if ($@ =~ /Missing required parameter 'callback_confirmed'/) {
# fall back to OAuth 1.0
$response = Net::OAuth->response('request token')-
>from_post_body(
$res->content,
protocol_version => Net::OAuth::PROTOCOL_VERSION_1_0
);
$is_oauth_1_0 = 1; # from now on treat the server as OAuth
1.0 compliant
}
else {
die $@;
}
}
At some point in the future, Net::OAuth will default to
Net::OAuth::PROTOCOL_VERSION_1_0A.