WebApi/Oauth/V2.pm

filter: Statementstmt 100% 25 / 25 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 2 totaltotal 94.2% 33 / 35 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« WebApi/Base.pm ↑ Summary WebApi/Dialog.pm »
1 package WebService::Slack::WebApi::Oauth::V2;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use feature qw/ state /;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use MIME::Base64 qw/ encode_base64 /;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 ▶use parent 'WebService::Slack::WebApi::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # override
12 2 ▶sub base_name { 'oauth.v2' }
Subroutine base_name: called CC=1 SCAR=0.0
Pod undocumented
13  
14 2 ▶sub access {
Subroutine access: called CC=1 SCAR=0.0
Pod undocumented
15 # Attn. client_id and client_secret are optional parameters for Slack
16 # because Slack makes it possible to authenticate either
17 # by using them or by setting an HTTP Auth header.
18 # https://api.slack.com/methods/oauth.v2.access
19 # But here we make the parameters mandatory because
20 # they are needed to call this method in any case.
21 2 state $rule = Data::Validator->new(
22 code => 'Str',
23 client_id => { isa => 'Str', optional => 0 },
24 client_secret => { isa => 'Str', optional => 0 },
25 redirect_uri => { isa => 'Str', optional => 1 },
26 )->with('Method');
27 2 my ($self, $args) = $rule->validate(@_);
28  
29 2 my $t = encode_base64( $args->{'client_id'} . q{:} . $args->{'client_secret'}, q{} );
30 2 my $basic_auth = 'Basic ' . $t;
31 return $self->request('access', {
32 code => $args->{'code'},
33 2 redirect_uri => $args->{'redirect_uri'},
34 http_auth => $basic_auth,
35 }
36 );
37 }
38  
39 3 1;
40  
« WebApi/Base.pm ↑ Summary WebApi/Dialog.pm »