File Coverage

lib/Plack/Middleware/OAuth/Handler/RequestTokenV2.pm
Criterion Covered Total %
statement 9 19 47.3
branch n/a
condition 0 5 0.0
subroutine 3 5 60.0
pod 2 2 100.0
total 14 31 45.1


line stmt bran cond sub pod time code
1             package Plack::Middleware::OAuth::Handler::RequestTokenV2;
2 2     2   11 use warnings;
  2         4  
  2         88  
3 2     2   12 use strict;
  2         4  
  2         110  
4 2     2   12 use parent qw(Plack::Middleware::OAuth::Handler);
  2         3  
  2         18  
5              
6             sub default_callback {
7 0     0 1   my $self = shift;
8 0           my $provider = $self->provider;
9 0           my $env = $self->env;
10             # 'REQUEST_URI' => '/oauth/twitter',
11             # 'SCRIPT_NAME' => '/oauth',
12             # 'PATH_INFO' => '/twitter',
13 0           return URI->new( $env->{'psgi.url_scheme'} . '://' .
14             $env->{HTTP_HOST} . $env->{SCRIPT_NAME} . '/' . lc($provider) . '/callback' );
15             }
16              
17             sub run {
18 0     0 1   my $self = shift;
19 0           my $config = $self->config;
20              
21             # "https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL";
22 0           my $uri = URI->new( $config->{authorize_url} );
23 0   0       my %query = (
      0        
24             client_id => $config->{client_id},
25             redirect_uri => $config->{redirect_uri} || $self->default_callback,
26             response_type => $config->{response_type} || 'code',
27             scope => $config->{scope},
28             );
29 0           $uri->query_form( %query );
30 0           return $self->redirect( $uri );
31             }
32              
33             1;