sub
build_args {
my
$self
=
$_
[0];
my
$config
=
$self
->config;
return
(
$self
->build_v1_common_args,
request_url
=>
$config
->{request_token_url},
request_method
=>
$config
->{request_token_method},
callback
=>
$config
->{callback} ||
$self
->default_callback,
);
}
sub
run {
my
$self
=
shift
;
my
$config
=
$self
->config;
$Net::OAuth::PROTOCOL_VERSION
= Net::OAuth::PROTOCOL_VERSION_1_0A;
my
$ua
= LWP::UserAgent->new;
my
$request
= Net::OAuth->request(
"request token"
)->new(
$self
->build_args );
$request
->sign;
my
$res
=
$ua
->request(POST
$request
->to_url);
if
(
$res
->is_success) {
my
$response
= Net::OAuth->response(
'request token'
)->from_post_body(
$res
->content);
my
$uri
= URI->new(
$config
->{authorize_url} );
$uri
->query_form(
oauth_token
=>
$response
->token );
return
$self
->redirect(
$uri
);
}
$self
->on_error->(
$self
)
if
$self
->on_error;
return
$self
->render(
$res
->content );
}
1;