.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.ie \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.el \{\
. de IX
..
.\}
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "LWP::Authen::OAuth 3pm"
.TH LWP::Authen::OAuth 3pm "2011-03-31" "perl v5.12.3" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
LWP::Authen::OAuth \- generate signed OAuth requests
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& require LWP::Authen::OAuth;
.Ve
.SS "Google"
.IX Subsection "Google"
.Vb 5
\& # Google uses \*(Aqanonymous\*(Aq for unregistered Web/offline applications or the
\& # domain name for registered Web applications
\& my $ua = LWP::Authen::OAuth\->new(
\& oauth_consumer_secret => "anonymous",
\& );
\&
\& # request a \*(Aqrequest\*(Aq token
\& my $r = $ua\->post( "https://www.google.com/accounts/OAuthGetRequestToken",
\& [
\& oauth_consumer_key => \*(Aqanonymous\*(Aq,
\& oauth_callback => \*(Aqhttp://example.net/oauth\*(Aq,
\& xoauth_displayname => \*(AqExample Application\*(Aq,
\& scope => \*(Aqhttps://docs.google.com/feeds/\*(Aq,
\& ]
\& );
\& die $r\->as_string if $r\->is_error;
\&
\& # update the token secret from the HTTP response
\& $ua\->oauth_update_from_response( $r );
\&
\& # open a browser for the user
\&
\& # data are returned as form\-encoded
\& my $uri = URI\->new( \*(Aqhttp:\*(Aq );
\& $uri\->query( $r\->content );
\& my %oauth_data = $uri\->query_form;
\&
\& # Direct the user to here to grant you access:
\& # https://www.google.com/accounts/OAuthAuthorizeToken?
\& # oauth_token=$oauth_data{oauth_token}\en";
\&
\& # turn the \*(Aqrequest\*(Aq token into an \*(Aqaccess\*(Aq token with the verifier
\& # returned by google
\& $r = $ua\->post( "https://www.google.com/accounts/OAuthGetAccessToken", [
\& oauth_consumer_key => \*(Aqanonymous\*(Aq,
\& oauth_token => $oauth_data{oauth_token},
\& oauth_verifier => $oauth_verifier,
\& ]);
\&
\& # update the token secret from the HTTP response
\& $ua\->oauth_update_from_response( $r );
\&
\& # now use the $ua to perform whatever actions you want
.Ve
.SS "Twitter"
.IX Subsection "Twitter"
Sending status updates to a single account is quite easy if you create an application. The \f(CW\*(C`oauth_consumer_key\*(C'\fR and \f(CW\*(C`oauth_consumer_secret\*(C'\fR come from the 'Application Details' page and the \f(CW\*(C`oauth_token\*(C'\fR and \f(CW\*(C`oauth_token_secret\*(C'\fR from the 'My Access Token' page.
.PP
.Vb 6
\& my $ua = LWP::Authen::OAuth\->new(
\& oauth_consumer_key => \*(Aqxxx1\*(Aq,
\& oauth_consumer_secret => \*(Aqxxx2\*(Aq,
\& oauth_token => \*(Aqyyy1\*(Aq,
\& oauth_token_secret => \*(Aqyyy2\*(Aq,
\& );
\&
\& $ua\->post( \*(Aqhttp://api.twitter.com/1/statuses/update.json\*(Aq, [
\& status => \*(AqPosted this using LWP::Authen::OAuth!\*(Aq
\& ]);
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This module provides a sub-class of LWP::UserAgent that generates OAuth 1.0 signed requests. You should familiarise yourself with OAuth at .
.PP
This module only supports \s-1HMAC_SHA1\s0 signing.
.PP
OAuth nonces are generated using the Perl random number generator. To set a nonce manually define 'oauth_nonce' in your requests via a \s-1CGI\s0 parameter or the Authorization header \- see the OAuth documentation.
.SH "METHODS"
.IX Header "METHODS"
.ie n .IP "$ua = LWP::Authen::OAuth\->new( ... )" 4
.el .IP "\f(CW$ua\fR = LWP::Authen::OAuth\->new( ... )" 4
.IX Item "$ua = LWP::Authen::OAuth->new( ... )"
Takes the same options as \*(L"new\*(R" in LWP::UserAgent plus optionally:
.Sp
.Vb 4
\& oauth_consumer_key
\& oauth_consumer_secret
\& oauth_token
\& oauth_token_secret
.Ve
.Sp
Most services will require some or all of these to be set even if it's just 'anonymous'.
.ie n .IP "$ua\->oauth_update_from_response( $r )" 4
.el .IP "\f(CW$ua\fR\->oauth_update_from_response( \f(CW$r\fR )" 4
.IX Item "$ua->oauth_update_from_response( $r )"
Update the \f(CW\*(C`oauth_token\*(C'\fR and \f(CW\*(C`oauth_token_secret\*(C'\fR from an HTTP::Response object returned by a previous request e.g. when converting a request token into an access token.
.ie n .IP "$key = $ua\->oauth_consumer_key( [ \s-1KEY\s0 ] )" 4
.el .IP "\f(CW$key\fR = \f(CW$ua\fR\->oauth_consumer_key( [ \s-1KEY\s0 ] )" 4
.IX Item "$key = $ua->oauth_consumer_key( [ KEY ] )"
Get and optionally set the consumer key.
.ie n .IP "$secret = $ua\->oauth_consumer_secret( [ \s-1SECRET\s0 ] )" 4
.el .IP "\f(CW$secret\fR = \f(CW$ua\fR\->oauth_consumer_secret( [ \s-1SECRET\s0 ] )" 4
.IX Item "$secret = $ua->oauth_consumer_secret( [ SECRET ] )"
Get and optionally set the consumer secret.
.ie n .IP "$token = $ua\->oauth_token( [ \s-1TOKEN\s0 ] )" 4
.el .IP "\f(CW$token\fR = \f(CW$ua\fR\->oauth_token( [ \s-1TOKEN\s0 ] )" 4
.IX Item "$token = $ua->oauth_token( [ TOKEN ] )"
Get and optionally set the oauth token.
.ie n .IP "$secret = $ua\->oauth_token_secret( [ \s-1SECRET\s0 ] )" 4
.el .IP "\f(CW$secret\fR = \f(CW$ua\fR\->oauth_token_secret( [ \s-1SECRET\s0 ] )" 4
.IX Item "$secret = $ua->oauth_token_secret( [ SECRET ] )"
Get and optionally set the oauth token secret.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
LWP::UserAgent, MIME::Base64, Digest::SHA, \s-1URI\s0, URI::Escape
.SS "Rationale"
.IX Subsection "Rationale"
I think the complexity in OAuth is in the parameter normalisation and message signing. What this module does is to hide that complexity without replicating the higher-level protocol chatter.
.PP
In Net::OAuth:
.PP
.Vb 10
\& $r = Net::OAuth\->request(\*(Aqrequest token\*(Aq)\->new(
\& consumer_key => \*(Aqxxx\*(Aq,
\& request_url => \*(Aqhttps://photos.example.net/request_token\*(Aq,
\& callback => \*(Aqhttp://printer.example.com/request_token_ready\*(Aq,
\& ...
\& extra_params {
\& scope => \*(Aqglobal\*(Aq,
\& }
\& );
\& $r\->sign;
\& $res = $ua\->request(POST $r\->to_url);
\& $res = Net::OAuth\->response(\*(Aqrequest token\*(Aq)
\& \->from_post_body($res\->content);
\& ... etc
.Ve
.PP
In LWP::Authen::OAuth:
.PP
.Vb 10
\& $ua = LWP::Authen::OAuth\->new(
\& oauth_consumer_key => \*(Aqxxx\*(Aq
\& );
\& $res = $ua\->post( \*(Aqhttps://photos.example.net/request_token\*(Aq, [
\& oauth_callback => \*(Aqhttp://printer.example.com/request_token_ready\*(Aq,
\& ...
\& scope => \*(Aqglobal\*(Aq,
\& ]);
\& $ua\->oauth_update_from_response( $res );
\& ... etc
.Ve
.PP
Net::OAuth, OAuth::Lite.
.SH "AUTHOR"
.IX Header "AUTHOR"
Timothy D Brody
.PP
Copyright 2011 University of Southampton, \s-1UK\s0
.PP
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself