[Bps-public-commit] jifty-plugin-authentication-twitter branch, master, updated. fa9de59f2a68c55049b5cd897779702dc13364f2

Shawn Moore sartak at bestpractical.com
Fri Jun 4 11:33:13 EDT 2010


The branch, master has been updated
       via  fa9de59f2a68c55049b5cd897779702dc13364f2 (commit)
      from  5c90d1e569ee649a699fc45564eda4b7e6092dd4 (commit)

Summary of changes:
 .../Plugin/Authentication/Twitter/Dispatcher.pm    |   24 +++++++++++++++----
 1 files changed, 19 insertions(+), 5 deletions(-)

- Log -----------------------------------------------------------------
commit fa9de59f2a68c55049b5cd897779702dc13364f2
Author: Shawn M Moore <sartak at gmail.com>
Date:   Fri Jun 4 11:33:53 2010 -0400

    Redirect the user to twitter's /oauth/authenticate

diff --git a/lib/Jifty/Plugin/Authentication/Twitter/Dispatcher.pm b/lib/Jifty/Plugin/Authentication/Twitter/Dispatcher.pm
index b4d4d0a..d0d64f1 100644
--- a/lib/Jifty/Plugin/Authentication/Twitter/Dispatcher.pm
+++ b/lib/Jifty/Plugin/Authentication/Twitter/Dispatcher.pm
@@ -4,6 +4,10 @@ use warnings;
 package Jifty::Plugin::Authentication::Twitter::Dispatcher;
 use Jifty::Dispatcher -base;
 use Net::OAuth;
+use Net::OAuth::RequestTokenRequest;
+use Net::OAuth::RequestTokenResponse;
+use Net::OAuth::UserAuthRequest;
+use Net::OAuth::UserAuthResponse;
 use HTTP::Request::Common ();
 
 =head1 NAME
@@ -35,11 +39,11 @@ before '/twitter/callback' => run {
 
 on '/twitter/login' => run {
     my ($plugin) = Jifty->find_plugin('Jifty::Plugin::Authentication::Twitter');
-    my $request_token_request = Net::OAuth->request("request token")->new(
+    my $request_token_request = Net::OAuth::RequestTokenRequest->new(
         consumer_key     => $plugin->consumer_key,
         consumer_secret  => $plugin->consumer_secret,
-        request_url      => 'http://twitter.com/oauth/request_token',
         request_method   => 'POST',
+        request_url      => 'http://twitter.com/oauth/request_token',
         signature_method => 'HMAC-SHA1',
         timestamp        => time,
         nonce            => $$ * rand,
@@ -53,9 +57,19 @@ on '/twitter/login' => run {
         die "Something went wrong";
     }
 
-    my $response = Net::OAuth->response('request token')->from_post_body($res->content);
-    # $response->token;
-    # $response->token_secret;
+    my $response = Net::OAuth::RequestTokenResponse->from_post_body($res->content);
+
+    my $auth_request = Net::OAuth::UserAuthRequest->new(
+        consumer_key     => $plugin->consumer_key,
+        consumer_secret  => $plugin->consumer_secret,
+        token            => $response->token,
+        request_method   => 'POST',
+        signature_method => 'HMAC-SHA1',
+        timestamp        => time,
+        nonce            => $$ * rand,
+    );
+
+    Jifty->web->_redirect($auth_request->to_url('http://twitter.com/oauth/authenticate'));
 };
 
 1;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list