The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::OAuth::Easy - A moose class that abstracts Net::OAuth for you

VERSION

version 0.001_05

ATTRIBUTES

ua

A LWP::UserAgent object to do the message passing.

protocol

What OAuth protocol do you wish your messages to be build in?

  • '1.0a' Default

  • '1.0'

consumer_key

consumer_secret

request_token_url

authorize_token_url

access_token_url

callback

request_method

Defines the method of the request.

  • 'GET' Default

  • 'POST'

signature_method

Defines the method to sign the request.

  • 'HMAC-SHA1' Default

  • 'RSA-SHA1'

signature_key

Where to find the signature key, only used for RSA-SHA1 type signatures.

Expected to be passed a Crypt::OpenSSL::RSA object. Though if passed a string, this will be assumped to be a filename and will be passed to the new_private_key method of Crypt::OpenSSL::RSA.

request_parameters

This is a HashRef of ArrayRefs that is used to define the required elements of each type of OAuth request. The type (ie request_token) is the key and all items in the ArrayRef value will be collected from $self if not passed at the time that the request is built.

exception_handle

Stores a coderef that is called when an exception is hit. Out of the box this does not do anything more then die with a message, though it can be used to leverage diffrent codepaths at the time of an exception.

It is used internaly as such:

  $self->exception_handle->(q{unable to sign request});

Thus if you need to define your own you will have $self and a note about why it was called.

I'm not completely happy with this so it could change but this should get any one needing this the most basic items currently.

response

Stores the response when any of the get_* methods are called.

oauth_header_realm

If defined it is expected to be a string(URL) that will be included in to the Authorization headers. If not given it will be ignored.

oauth_header_separator

A string that denotes the string that you would like to use to seperate the key=value pairs in the Authuntication header.

Defaults to ','.

request_token

Stores the request_token when it's collected via get_request_token.

request_token_secret

Stores the request_token_secret when it's collected via get_request_token.

access_token

Stores the access_token when it's collected via get_request_token.

access_token_secret

Stores the access_token_secret when it's collected via get_request_token.

process_access_token_mapping

METHODS

has_consumer_key

clear_consumer_key

has_consumer_secret

clear_consumer_secret

has_request_token_url

clear_request_token_url

has_authorize_token_url

clear_authorize_token_url

has_access_token_url

clear_access_token_url

has_callback

clear_callback

has_signature_key

clear_signature_key

timestamp

Currently just an alias to time, it is used to define the timestamp of the OAuth request.

nonce

Define a unique id for every OAuth request, curently this is done by taking the md5_hex of two random numbers and the time.

build_request

Used to build the Net::OAuth request object based on input and gather_request_parts.

gather_request_parts

Uses request_parameters to merge passed items with stored values to complete all items required for build_request.

has_response

clear_response

content

Shortcut to get the content of the response, will return undef if in the case of no response yet stored.

success

Shortcut to see if a successful response was collected, returns 0 in the case of no response yet stored.

failure

Returns the inverse of success.

error

In the case of a non-successful response, will return a formated string that includes the status_line and content to describe the reason for failure. Will return undef in the case of no response yet stored.

make_request

Given a Net::OAuth request, convert it to a HTTP::Request such that it can be sent via ua. One other thing to note is that make_request also calls clear_request thus destroying any previously stored request.

add_auth_headers

Add the Authentication header to the HTTP request based on the OAuth request if the request method is POST.

send_request

Pass the given HTTP::Request object to ua thus sending out the request to the world.

has_request_token

clear_request_token

has_request_token_secret

clear_request_token_secret

has_access_token

clear_access_token

has_access_token_secret

clear_access_token_secret

get_request_token

Builds up an OAuth request to get the request_token pairs.

get_authorization_url

Build out the URL that is needed to be called to collect the oauth_verifier.

process_authorization_callback

Unpack the return url from the OAuth provider that includes items like oauth_verifier. Returns a hash of unparsed items.

process_access_token_input

get_access_token

Collect and store the access_tokens.

get_protected_resource

AUTHOR

  Ben Hengst <notbenh@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2010 by Ben Hengst.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 630:

Unknown directive: =roles