blib/lib/PEF/Front/Oauth/GitHub.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 61 CC 2 SCAR 9.8
CC
2
Cov
0%
_parse_user_info
6.0
_authorization_server
2.0
_token_request
2.0
CRAP 2.7
1 package PEF::Front::Oauth::GitHub;
2  
3 use strict;
4 use warnings;
5 use base 'PEF::Front::Oauth';
6 use HTTP::Request::Common;
7 use feature 'state';
8 use PEF::Front::Config;
9  
10 sub _authorization_server {
11 'https://github.com/login/oauth/authorize';
12 }
13  
14 sub _token_request {
15 my ($self, $code) = @_;
16 POST 'https://github.com/login/oauth/access_token',
17 [ code => $code,
18 client_id => cfg_oauth_client_id($self->{service}),
19 client_secret => cfg_oauth_client_secret($self->{service})
20 ],
21 Accept => 'application/json';
22 }
23  
24 sub _get_user_info_request {
25 my ($self) = @_;
26 my $req = GET 'https://api.github.com/user',
27 Authorization => 'token ' . $self->{session}->data->{oauth_access_token}{$self->{service}};
28 $req;
29 }
30  
31 sub _parse_user_info {
32 my ($self) = @_;
33 my $info = $self->{session}->data->{oauth_info_raw}{$self->{service}};
34 my @avatar = ();
35 @avatar = ({url => $info->{avatar_url}}) if $info->{avatar_url};
36 return {
37 name => $info->{name} || $info->{login} || '',
38 email => $info->{email} || '',
39 login => $info->{login} || '',
40 avatar => \@avatar,
41 };
42 }
43  
44 sub new {
45 my ($class, $self) = @_;
46 bless $self, $class;
47 }
48  
49 1;